Basic HTML version of Foils prepared Sept 20 97

Foil 46 The Matching Operator and
Regular Expressions

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


1 The result of the expression
2 $string =~ m/$regex/
3 is true if and only if the value of $string matches $regex.
4 For example,
5 if ( <STDIN> =~ m/^[Tt][Oo]:/ ) { ... }
6 matches if current input line starts with to: (any case)
7 Note: m/^to:/i is equivalent to above expression since modifier /i instructs pattern matcher to ignore case
8 Any delimiter may be used in place of the slash
9 m%^[Tt][Oo]:% # equivalent to previous expression
10 The m operator may be omitted, but then slash delimiters are required

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