Hello list, I am not so familiar with C syntax but I suspect that the circumflex changes the parsing method. What is the difference between these two:
first-> search("^(Contact|m): .*@(192.168.|10.|172.16)") second-> search("(From|f):.*@foo.bar")
Questions: 1. How does the circumflex affect the string inside ( ) 2. How is ( ) used?
Thanks, Che
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@192.168.0.1
but would not match
I wish to Contact: che.sosa@192.168.0.1
Have fun,
Paul
Hi there
it is not C syntax but regexp syntax, ^ means (at the beginning of the string) and parenteses with | inside means, "one of the following", so the first example will found
Contact: whatever@192.168. Contact: whatever@10. Contact: whatever@172.16. m: whatever@192.168. m: whatever@10. m: whatever@172.16.
but WILL NOT found
anythingContact: ... anythingm: ...
the second example will found both
From... anythingFrom...
you problably get the picture now
hope this helps !3runo
Che Sosa wrote:
Hello list, I am not so familiar with C syntax but I suspect that the circumflex changes the parsing method. What is the difference between these two:
first-> search("^(Contact|m): .*@(192.168.|10.|172.16)") second-> search("(From|f):.*@foo.bar")
Questions:
- How does the circumflex affect the string inside ( )
- How is ( ) used?
Thanks, Che