http://qs1969.pair.com?node_id=1181551


in reply to Basic Regular expression

The answer you get is what is expected. What do you think the regex reads like?

Start then capture 1 or more character upto "e" or "r" captured then capture anything left to end.

Remember the match is greedy so matches the "r" in the option rather than the "e".

Replies are listed 'Best First'.
Re^2: Basic Regular expression
by ikegami (Patriarch) on Feb 09, 2017 at 18:00 UTC

    Start then capture 1 or more character upto "e" or "r"

    If it was true, the OP would have received

    $1="This is P"; $2="e"; $3="rl";
    instead of
    $1="This is Pe"; $2="r"; $3="l";

    It actually matches until the end of the line as the OP expects, but its then forced to backtrack until it finds a position that's followed by e or r.