in reply to Re: Re: Re: Question on REGEX
in thread Question on REGEX

We're obviously differing in semantics, then :) I would say a* doesn't match bob because trying /(a*)/ wouldn't get you "bob".

In the examples you give, the regexer is satisfied, but I wouldn't say the regex a* matches bob. In my parlanace, I would say (for example) a(b|a) would match ab. Then, a* doesn't match bob because a(a|b)a*a(a|b) won't match abbobab.

Does anyone else share my terminology? Perhaps this is a function of the books we read...

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Question on REGEX
by merlyn (Sage) on May 14, 2001 at 19:55 UTC
    I think the distinction is "does this regex match that string" can be defined as "does this regex match that *ENTIRE* string" or "does this regex match the string over there, including taking any assertions into consideration". And both usages are equally valid use of the casual "match" word.

    So, to be clear, /(a*)/ "matches" bob, but not the "entire string of bob".

    -- Randal L. Schwartz, Perl hacker