in reply to Regex problem with .+ matching newlines without /s

What ccn said. If the thing to the right and left of the : need to be on the same line, use [^\S\n] instead of \s. Also, I think (.+?)? is a little on the obfuscated side. I would make from the : onward :[^\S\n]*(.*?)\s*$ (though I think that leaves $2 blank instead of undef.) (The final \s can be left as is unless you want to prevent the regex from swallowing up blank lines.)

Replies are listed 'Best First'.
Re^2: Regex problem with .+ matching newlines without /s
by Solo (Deacon) on Aug 31, 2004 at 18:55 UTC
    (.+?)? resulted from my (possibly obfuscated) thought process.

    [^\S\n] did the trick, thanks much. I rarely deal with multi-line matches and didn't know that about \s. Seems to me there ought to be an easier way to express non-newline whitespace than [^\S\n].

    --Solo

    --
    You said you wanted to be around when I made a mistake; well, this could be it, sweetheart.