tel2 has asked for the wisdom of the Perl Monks concerning the following question:
I understand that the regular expression /m modifier is supposed to let ^ and $ match next to embedded \n.
If that is the case, then why don't these match?
Instead, they give this output:perl -e '$_="ABC\nDEF";s/C$^D/-/m;print' perl -e '$_="ABC\nDEF";s/C$\n^D/-/m;print'
I know I can make it match like this:ABC DEF
which gives this output:perl -e '$_="ABC\nDEF";s/C\nD/-/;print'
And I didn't even need the /m modifier, but that doesn't answer my question.ABC-DEF
Thanks.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Why \n matches but not $^? (weight)
by tye (Sage) on Oct 13, 2008 at 04:41 UTC | |
by moritz (Cardinal) on Oct 13, 2008 at 09:06 UTC | |
by tye (Sage) on Oct 14, 2008 at 00:02 UTC | |
by tel2 (Pilgrim) on Oct 13, 2008 at 22:53 UTC | |
by moritz (Cardinal) on Oct 14, 2008 at 05:57 UTC | |
by tel2 (Pilgrim) on Oct 13, 2008 at 08:52 UTC | |
by ikegami (Patriarch) on Oct 13, 2008 at 13:56 UTC | |
by tye (Sage) on Oct 14, 2008 at 00:14 UTC | |
by procura (Beadle) on Oct 13, 2008 at 21:32 UTC |