Regular Expressions
Return to Introduction  Previous page  Next page
Regular expressions can take quite an effort to get right, but at the same time can be very powerful. VOPP supports most of the standard POSIX regex. A summary of regular expression terms and their meanings is included below. For a more detailed discussion please read
http://www.delorie.com/gnu/docs/regex/regex_toc.html

Match any character
n . (single)
e.g. d.g matches a string starting with d, ending with g, with any one character in between: dog will match, dg will not

Repetition operators
n * (zero or more)
e.g. do*g matches a string made up of zero or more "o" characters: dooog, doog, dog, dg all match

n + (one or more)
e.g. do+g matches a string made up of one or more "o" characters: dooog, doog, dog match, but dg doesn't

n ? (zero or one)
e.g. do?g matches zero or more "o" characters: dooog, doog don't match, but dog, dg do match

n {} (interval expression)
n {n} matches n occurrences of the preceding expression
n {n,} matches n or more occurrences of the preceding expression
n {n,m} matches at least n, but not more than m occurrences of the preceding expression

Anchoring
n ^ match beginning of line

Escape
n \ Escape character - use next character as is

Alternation
n | (or)
e.g. dog|cat will match dog or cat

Lists
n [] (set of one or more items)

n [ab] matches any a or b

n [^ab] matches any character except a or b

n [a-z] matches any alphabetic character

n [a-z0-9] matches any alphabetic or digit character

Grouping
n () (parentheses signify a regular expression group)

Replace
n & insert the original string found

n #0, #1, etc Each parentheses set, (), in the search expression denotes a group. Group numbering starts at zero. Specifying #n in the replace will insert the string that was matched by group n.


NOTE 1: spaces within regular expression _are_ significant

NOTE 2: see dimension example for important concept regarding matching





© Piko Computing Consultants, 1998-2002