So, in fseditor.js, I plan on implementing for regular expression stuff (you welcome Angus). However, I'm unsure of one teensly little thing...
Since fseditor does word wrapping, there isn't *really* an end of line unles the user presses enter... so, should /^(.*)$/ match a single wrapped line, o should it match from one CR to the next (in general, a complete paragraph)?
How should the m and s flags interact with this?
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 D User posted something about Dumb User and I wanted to quickly do a nice simp s/Dumb User/Idiot/g and it only matches one. I mean... it's going to need t rewrap after a replacement anyways.
iirc, in general, ^ and $ match the beginning an 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 expec 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.
yada yada yada yada yada yada yada yada yada yada yada yada Dumb
User yada yada yada yada yada yada yada
The s flag wouldn't need any special handling at all since it merely expa what . matches to include newlines. So your example would work as you ex 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);
Which seems to me to be intuitive.
Further, if it included soft CRs, that would be an extra bit of whitespac where there "really" isnt.
Well, the separation between the last word on one line and the first word
on the next is in fact "whitespace". Whether it is a space character or a newline, it is still whitespace and matches \s. So if you treated a soft
CR like a hard CR, you're doing the right thing, because (presumably) for the auto-wordwrap to ahve kicked in, the user must have tyoed a space or
tab or something at that point in the input text.
To completely throw a spanner in the works: Quoting. How will you treat something like
> yada yada yada yada yada yada yada yada yada yada yada yada Dumb
> User yada yada yada yada yada yada yada
when searching for /Dumb User/ or even /Dubm\s/User/m ? ;-)
The fix is simply to use the correct flags
The fix is simply to use the correcty flags in the regex... m or s as a
The fix is simply to use the correcty flags in the regex... m or s as appropriate.
To completely throw a spanner in the works: Quoting. How will you treat something like
> yada yada yada yada yada yada yada yada yada yada yada yada Dumb
> User yada yada yada yada yada yada yada
when searching for /Dumb User/ or even /Dubm\s/User/m ? ;-)
Well, I can't say it seems completely intuitive, since your example would actually not have done what you said it would have. :-)
As for adding a soft CR, the spaces are *still* at the end of the line... so soft CRs were expanded to hard, you'd need /Dumb\s+User/ reather than /Dumb\sUser/ or /Dumb User/
As for quoting, I plan on using Deep Magic for it when possible.
And possibly even rewrapping it to fit in the smaller width.
The fix is simply to use the correcty flags in the regex... m or s a appropriate.
Huh? I *know* it won't match because of th > characters. But should theI meant the original /^Para/ example.
qu otation symbol be treated as whitespace (thus matching with \s) when applying R E's to quote > messing with ya....
Oh, OK, I didn't realise that you left the spYeah, the spaces are at the end of the line for my convienience. In "theory" they actually exist in limbo between the two lines for the purposes if the m flag.
But what I'm saying is that I should be able to match
User is auto-wrapped at line end (like that). If
and "Dumb" is at the end of the line, I *ough
against it with /Dumb$/m withOU T having to guess whether
invisible space after the word, or whether that li ne break occured implicitly due to line-wrap or explicitly due to the press of the ENT > key.
Re: RegExp Behaviour in FSEeat > > > something like
By: Deuce to Angus McLeod on Thu Mar 02 2006 12:45:00
To completely throw a spanner in the works: Quoting. How will you tr
b> yada yada yada yada yada yada yada yada yada yada yada yada Dum
Hrm... did that fix teh high intensity issue?> User yada yada yada yada yada yada yada
when searching for /Dumb User/ or even /Dubm\s/User/m ? ;-)
Well, I can't say it seems completely intuitive, since your example would actually not have done what you said it would have. :-)
Huh? I *know* it won't match because of th > characters. But should the qu Oh, OK, I didn't realise that you left the sp > But what I'm saying is that
Huh? I *know* it won't match because of th > characters. But should the Oh, OK, I didn't realise that you left the sp > But what I'm saying is thHrm... did that fix teh high intensity issue?
Sysop: | Ree |
---|---|
Location: | Toronto, ON |
Users: | 2 |
Nodes: | 10 (0 / 10) |
Uptime: | 111:59:21 |
Calls: | 374 |
Calls today: | 1 |
Files: | 2 |
Messages: | 38,881 |