[Serusers] search string, circumflex

Paul Jankowski paul at teragen.com.au
Wed Apr 20 09:41:36 CEST 2005


> first-> search("^(Contact|m): .*@(192\.168\.|10\.|172\.16)")
> second-> search("(From|f):.*@foo.bar")

The string is a regular expression.  You can find out more about them
online (eg: http://sitescooper.org/tao_regexps.html ), or by typing

  man 7 regex

at the command line.


"(Contact|m)" means 'either the word "Contact" or the word "m"'.

A caret ^ at the beginning of the regular expression means "only match
if the following string is at the beginning of the line" -- so the first
expression would match

  Contact: che.sosa at 192.168.0.1

but would not match 

  I wish to Contact: che.sosa at 192.168.0.1

Have fun,

Paul

-- 
P-a-u-l- -J-a-n-k-o-w-s-k-i                              paul at teragen.com.au

 "A programmer," he said with obvious amazement, is the sort of person "who
 drinks Coke in the morning."  -- Boston Globe article on The High Tech Set




More information about the sr-users mailing list