-
RegExp Behaviour in FSE
From
Deuce@VERT/SYNCNIX to
All on Tue Feb 28 23:42:00 2006
So, in fseditor.js, I plan on implementing for regular expression stuff (yourãwelcome Angus). However, I'm unsure of one teensly little thing...ããSince fseditor does word wrapping, there isn't *really* an end of line unlessãthe user presses enter... so, should /^(.*)$/ match a single wrapped line, orãshould it match from one CR to the next (in general, a complete paragraph)?ããHow should the m and s flags interact with this?ãã---ãThis sig is not directed at Jazzman.ãã---ã þ Synchronet þ My Brand-New BBS (All the cool SysOps run STOCK!)ã
-
From
Angus McLeod@VERT/ANJO to
Deuce on Wed Mar 1 10:22:00 2006
Re: RegExp Behaviour in FSEã By: Deuce to All on Tue Feb 28 2006 23:42:00ãã > So, in fseditor.js, I plan on implementing for regular expression stuff (youã > welcome Angus). However, I'm unsure of one teensly little thing...ããAppreciated!ãã > 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?ããOkay, my immediate thoughts: The RE applies to a string. What string ãwill it apply to? Presumably, selected text, or the entire document, ãdepending.ãã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?ãããã---ãPlaying: "Try & love again" by "Eagles"ã from the "Hotel California" albumã þ Synchronet þ Making sure Jason works OK at The ANJO BBSã
-
From
Deuce@VERT/SYNCNIX to
Angus McLeod on Wed Mar 1 20:21:00 2006
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!)ã
-
From
Angus McLeod@VERT/ANJO to
Deuce on Thu Mar 2 00:54:00 2006
Re: RegExp Behaviour in FSEã By: Deuce to Angus McLeod on Wed Mar 01 2006 20:21:00ãã > 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.ããHmmm. /s makes "." match "\n" but that about "\s" ? maybe you need to ãdo something like s/Dumb\sUser/Idiot/sg and let the \s match the ãwhitespace between "Dumb" and "User".ããLook, people who want to use complex RE's will simply have to *learn* ãcomplex RE's. ãã > iirc, in general, ^ and $ match the beginning an end of a *STRING* not ã > a line. ããCorrect. It doesn't apply to "lines" at all, unless of course, you store ãthat line in a string. ãã > So the m flag would make ^ and $ match lines.ããExactly. Assuming that you treat a soft CR as a newline for the purposes ãof ^ and $ same as a hard CR. ãã > 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);ããWhich seems to me to be intuitive.ãã > Further, if it included soft CRs, that would be an extra bit of whitespaceã > 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 ? ;-)ãããã---ãPlaying: "Smokin Banana Peels" by "The Dead Milkmen"ã from the "Death Rides a Pale Cow" albumã þ Synchronet þ Making sure Jason works OK at The ANJO
BBSã
-
From
Deuce@VERT/SYNCNIX to
Angus McLeod on Thu Mar 2 12:45:00 2006
Re: RegExp Behaviour in FSEã By: Angus McLeod to Deuce on Thu Mar 02 2006 12:54 amãã > > 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 ? ;-)ãã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 ifã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. Since thisãeditor is runnign inside of Synchronet, thanks to reply linking, there's a VERYãgood chance that the editor can actually read from the original message itselfãand requote to fit... ie: it could restore the missing data from this:ããDE> AM> DE> AM> DE> AM> DE> AM> DE> The fix is simply to use the correct flagsããTo this:ããx8> DE> The fix is simply to use the correcty flags in the regex... m or s as aããAnd possibly even rewrapping it to fit in the smaller width.ããx8> DE> The fix is simply to use the correcty flags in the regex... m or s asãx8> DE> appropriate.ããThe quoting indicators wouldn't count as part of the string.ãã---ãThis sig is not directed at Jazzman.ãã---ã þ Synchronet þ My Brand-New BBS (All the cool SysOps run STOCK!)ã
-
From
Angus McLeod@VERT/ANJO to
Deuce on Fri Mar 3 01:51:00 2006
Re: RegExp Behaviour in FSEã 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 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. :-)ããHuh? I *know* it won't match because of the > and the extra whitespace ãcharacters. But should the quotation symbol be treated as whitespace ã(thus matching with \s) when applying RE's to quoted text? ;-) Just ãmessing with ya....ãã > 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/ããOh, OK, I didn't realise that you left the space at the end of the line. ãBut what I'm saying is that I should be able to match /Dumb$/m when Dumb ãUser is auto-wrapped at line end (like that). If I'm looking at the text ãand "Dumb" is at the end of the line, I *ought* to be able to match ãagainst it with /Dumb$/m withOUT having to guess whether there was an ãinvisible space after the word, or whether that line break occured ãimplicitly due to line-wrap or explicitly due to the press of the ENTER ãkey. ãã > As for quoting, I plan on using Deep Magic for it when possible.ãã > And possibly even rewrapping it to fit in the smaller width.ã > ã > x8> DE> The fix is simply to use the correcty flags in the regex... m or s aã > x8> DE> appropriate.ããHmmm.ãã---ãPlaying: "2000 Miles" by "Pretenders"ã from the "Learning to crawl" albumã þ Synchronet þ Making sure Jason works OK at The ANJO BBSã
-
From
Deuce@VERT/SYNCNIX to
Angus McLeod on Fri Mar 3 12:04:00 2006
Re: RegExp Behaviour in FSEã By: Angus McLeod to Deuce on Fri Mar 03 2006 01:51 amãã Re: RegExp Behaviour in FSEã By: Deuce to Angus McLeod on Thu Mar 02 2006 12:45:00ã > Huh? I *know* it won't match because of th > characters. But should theã > qu otation symbol be treated as whitespace (thus matching with \s) whenã > applying R E's to quote > messing with ya....ãI meant the original /^Para/ example.ã > Oh, OK, I didn't realise that you left the spã > 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.ãYeah, 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.ãã---ãThis sig is not directed at Jazzman.ãã---ã þ Synchronet þ My Brand-New BBS (All the cool SysOps run STOCK!)ã
-
From
Deuce@VERT/SYNCNIX to
Angus McLeod on Fri Mar 3 12:07:00 2006
Re: RegExp Behaviour in FSEã By: Angus McLeod to Deuce on Fri Mar 03 2006 01:51 amãã > Re: RegExp Behaviour in FSEã > 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ãeat > > > something likeã > > >ã > > > > yada yada yada yada yada yada yada yada yada yada yada yada Dumãbã > > > > 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ãHrm... did that fix teh high intensity issue?ãã---ãThis sig is not directed at Jazzman.ãã---ã þ Synchronet þ My Brand-New BBS (All the cool SysOps run STOCK!)ã
-
From
Angus McLeod@VERT/ANJO to
Deuce on Sat Mar 4 01:25:00 2006
Re: RegExp Behaviour in FSEã By: Deuce to Angus McLeod on Fri Mar 03 2006 12:07:00ãã > > 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 thã > Hrm... did that fix teh high intensity issue?ããI don't think so...ãã---ãPlaying: "Traveller in time" by "Uriah Heep"ã from the "Demons & wizards" albumã þ Synchronet þ Making sure Jason works OK at The ANJO BBSã