Regular expressions

Regular expressions are used to check strings for a certain criteria. Be aware that it is up to the software developer to support regular expression, but also to create them or even deviate from the following regular expressions.

Character description

^ Matches the beginning of the line

$ Matches the end of the line

. Matches any single character

* Will match zero or more occurrences of the previous character

[ ] Matches all the characters inside the [ ]

Examples

/./ Will match any line that contains at least one character

/../ Will match any line that contains at least two characters

/^#/ Will match any line that begins with a '#'

/^$/ Will match all blank lines

/}^/ Will match any lines that ends with '}' (no spaces)

/} *^/ Will match any line ending with '}' followed by zero or more spaces

/[abc]/ Will match any line that contains a lowercase 'a', 'b', or 'c'

/^[abc]/ Will match any line that begins with an 'a', 'b', or 'c'

Ranges of characters

[a-x]*

[:alnum:] Alphanumeric [a-z A-Z 0-9]

[:alpha:] Alphabetic [a-z A-Z]

[:blank:] Spaces or tabs

[:cntrl:] Any control characters

[:digit:] Numeric digits [0-9]

[:graph:] Any visible characters (no whitespace)

[:lower:] Lower-case [a-z]

[:print:] Non-control characters

[:punct:] Punctuation characters

[:space:] Whitespace

[:upper:] Upper-case [A-Z]

[:xdigit:] hex digits [0-9 a-f A-F]


Linurs startpage