Regular Expressions
From Initq
Understanding Regular Expressions
theer are two types expressions: basic and extended. Some programms use basic and some use extended, it all depends on the program you are using.
- Bracket expressions
- [] matches any one character within the brackets. example b[aeiou]g matches bag,beg,big,bog and bug.
- Range expression
- a[2-4]z will match a2z, a3z and a4z
- Any single character
- a.z will match a2z, aBz or anything one character between a and z except for a new line.
- Start and end of line
- The carat(^) represents the start of line and dollar sign($) represents the end of line.
- Repetition operators
- A regular expression may be followed by a special symbol to denote how many times a matching item must exist.
- (*) zero or more, normally combined with .* to match with any substring.
- (+) one or more
- (?) zero or one
- Multiple possible strings
- (|) vertical bar seperates two possible matches. cat|truck
- Parentheses
- () surrounding subexpressions
- Escaping
- if you want to match a special character line a dot you will need to escape it. pakistan\.example\.com
