Basic HTML version of Foils prepared April 16,1996

Foil 44 (?..) Constructs in Regular Expressions - I

From Perl5 and Advanced Perl4 Features Computational Science for Information Age Course CPS616 Material -- April 16,1996. by Geoffrey C. Fox


(?#comment) is a comment in a regular expression
  • m/[aA][bB](?#matches aB Ab ab AB)/; # is example
/x modifier interprets whitespace in regular expression as for readability and not as "real" characters -- the Perl manual gives an example shown below which removes /* .. */ from C programs
$program =~ s{
  • /\* # match opening delimiter /*
  • .*? # minimal match to anything
  • \*/ # closing delimiter */
}[]gsx; # Replace with nothing (i.e. remove) and specify modifiers g s and x to be operational



© 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 Sat Sep 6 1997