Well I'm honest - I wrote these lines cos I'm always forgetting the syntax of regexp and there is no good summary that fits my needs!
expression | meaning | examples | description |
---|---|---|---|
[ ] | bracket | [a-z] | all characters from a to z |
( ) | (name) | match the string name | |
[A-Z] | all characters from A to Z | ||
[a-z0-9] | all characters from a to z or 0 to 9 | ||
. | dot | [0-9]. | match any digit, match any character |
{ } | repetition | [a-z]{2} | there are exactly 2 characters from a to z |
[a-z]{0,} | there is 1 or more characters from a to z | ||
[a-z]{2,5} | there is 2 but not more than 5 characters from a to z | ||
? | optional-repetition | [a-z]? | there are 0 or 1 characters from a to z |
* | repetition | [a-z]* | there are 0 or more characters from a to z |
+ | existing-repetition | [a-z]+ | there are 1 or more characters from a to z |
\b | empty string at the edge of a word | [0-9]\b | any number, not included in a word |
\B | empty string not at the edge of a word | [0-9]\B | any number, in a word |
^ | beginning of a line | ^(#) | a line, that starts with # |
$ | end of a line | (#)$ | a line, that ends with # |
| | OR operator | [a-z]| [0-9] | means [a-z] OR [0-9] |
\b([a-zA-Z0-9-_]+@{1}[a-zA-Z0-9-_]{2,}([a-zA-Z0-9-]+([.][a-zA-Z0-9]+[-]*[a-zA-Z0-9]+)+)+)
^#
\b(0x)[0-9a-fA-F]{2,}[hH]?|\b(0x)?[0-9a-fA-F]{2,}[hH]
\b[01]{2,}[bB]
?> PASSWD_ENTRY=$(/bin/grep --regexp="^$USER\b" /etc/passwd)