Subj : RegExp Behaviour in FSE
To   : Angus McLeod
From : Deuce
Date : Wed Mar 01 2006 08:21 pm

 Re: RegExp Behaviour in FSE
 By: Angus McLeod to Deuce on Wed Mar 01 2006 10:22 am

> Selected text *or* the entire document, might consist of several
> paragraphs.  Therefore, the un-flagged RE should refer to the entire
> unmodified string, selection or all.  The RE should (IMHO) treat both hard
> *and* soft newlines as newlines.  Soft newlines as inserted by an
> automated wordwrap are only a convenience for the user.  There shouldn't
> be any confusion.  If the user, looking at the text *sees* a newline, then
> the RE should respond as expected.  Were I to apply /^para/m to this
> parabraph, for instance, it should match *twice*, even though one instance
> of the word 'paragraph' was explicitly wrapped by the ENTER key, and the
> other was auto wrapped.
>
> The 'm' and 's' flags should modify the behaviour of the RE as normal, but
> (IMHO) it should treat *both* hard and soft newlines as newlines.
>
> Thoughts?

That's pretty much how I'm leaning.. was just worried about the case where Dumb
User posted something about Dumb User and I wanted to quickly do a nice simple
s/Dumb User/Idiot/g and it only matches one.  I mean... it's going to need to
rewrap after a replacement anyways.

The other option would be to use only hard CRs in the string, and allow the m
flag to use wrapped lines.  iirc, in general, ^ and $ match the beginning and
end of a *STRING* not a line.  So the m flag would make ^ and $ match lines.
The s flag wouldn't need any special handling at all since it merely expands
what . matches to include newlines.  So your example would work as you expected
with the m flag, and not match anything otherwise.  ie:

$_="Two line\nParagraphs\n";
print "No flags\n" if(/^Para/);
print "m flag\n" if(/^Para/m);

Further, if it included soft CRs, that would be an extra bit of whitespace
where there "really" isnt.

---
This sig is not directed at Jazzman.

---
� Synchronet � My Brand-New BBS (All the cool SysOps run STOCK!)