Basic HTML version of Foils prepared Sept 20 97

Foil 43 Some Regex Examples

From Tutorial on PERL Computational Science for Information Age Course CPS616 -- Sept 20 97. by Geoffrey C. Fox,Nancy McCracken,Tom Scavo


1 An integer with optional plus or minus sign
2 ^(\+|-)?[0-9]+$ (may use [-+]? as well)
3 Double-quoted strings, with no nested double quotes
4 "[^"]*" (matches the empty string "")
5 Double-quoted strings, with Fortran-like nested quotes
6 "([^"]|"")*"
7 Double-quoted strings, with C-like nested quotes
8 "([^"]|\\")*" (bugged! Why?)
9 "(\\"|[^"])*" (better, but still flawed)
10 "(\\"|[^"\\])*" (works, but inefficient)
11 "([^"\\]|\\")*" (works efficiently!)
12 Double-quoted strings, with other escaped characters
13 "([^"\\]|\\.)*" (but not escaped newlines)
14 "([^"\\]|\\(.|\n))*"

in Table To:


© Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Sun Sep 21 1997