http://www.perlmonks.org?node_id=1056800


in reply to perl look ahead regular expression that is optional?

Do you see where this contradicts?

compare: The second set of characters is always preceded by an X (...) and might contain (...) Only zero or one a, zero or one b, and zero or one c is (...)

to: foobarabcX must not match, nothing follows 'X'

I think it must match as X is followed by exactly zero "a"s, "b"s and "c"s.


s$$([},&%#}/&/]+}%&{})*;#$&&s&&$^X.($'^"%]=\&(|?*{%
+.+=%;.#_}\&"^"-+%*).}%:##%}={~=~:.")&e&&s""`$''`"e

Replies are listed 'Best First'.
Re^2: perl look ahead regular expression that is optional?
by bigsipper (Initiate) on Oct 04, 2013 at 00:54 UTC
    Yes, you are correct - as written it could be interpreted to mean that zero or more characters after the 'X' are allowed. My write up of the problem was in error. If there are ANY flags in the second set of characters, there is a 'X' preceding them. It is illegal to have an 'X' without a following character. The basics are correct, though. I have two optional sets of flags (single characters) that I need to parse out into separate variables. By the way... have tried to simplify the problem. I am trying to parse a much more complicated string set.
Re^2: perl look ahead regular expression that is optional?
by talexb (Chancellor) on Oct 04, 2013 at 13:34 UTC
      I think it must match as X is followed by exactly zero "a"s, "b"s and "c"s.

    My point exactly. I'm glad I'm not the only one who was confused by this inconsistency.

    Alex / talexb / Toronto

    Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.