[PLUG] Regular expressions

Paul Heinlein heinlein at attbi.com
Wed May 22 04:37:37 UTC 2002


On Tue, 21 May 2002, Sean, Sharon and Kyle Harbour wrote:

> Given an example like this:
> 
> (^|)(one|two|three|four)?
> 
> "one" is not a match, but "one two" or "three four" are.

What regex engine did you use for testing? Perl? sed? [e]grep? In
Perl, that regex would match any single string or line in a file; same
with egrep and sed, though the latter wouldn't be able to comprehend
it unless you escaped the metacharacters.

In every case, it should match the beginning of the line/string. Since 
the second group is entirely optional -- and since you don't rule out 
duplicate strings by anchoring the end of the string -- there are no 
disqualifying strings.

Can you post the file/stdin that you passed to the regex engine and 
the exact invocation of the utility you used to match it?

--Paul Heinlein <heinlein at attbi.com>






More information about the PLUG mailing list