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


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



© 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