Discussion › Forums › discussion › Replace w/ Regular Expressions: Unexpected Behaviour
This topic contains 0 voices and has 3 replies.
| Author | Posts |
|---|---|
| Author | Posts |
| August 23, 2009 at 11:19 am #669 | |
|
fedoracore Member
|
Hi. As somewhat a follower of ProsNpad & its RegEx Find and Replace functionality, I noticed in recent changelog reports that the RegEx has been updated. I thought it might be of help to report my experience while using Replace with regular expressions attempting to dissect some of what’s going on in the YUI(1) JavaScript library component, yahoo-dom-event.js Most of the time, everything works great (e.g. i often turn to ProsNpad for regular expression operations. for curiosity, i’ve done some amount of testing for differences between PN, other Scintilla-based editors, .NET-based editors, etc.), and I’ve been successful with it in some instances where i experienced difficulty with other editors (i.e. it’s amazing the variance between different “flavors”, as implemented in editors [to quote the Regex Buddy author's texts]) One of the several expressions I’ve used, is shown below– it’s one of a few which caused the unexpected result: Match Expression:
Replace Expression:
The unexpected result follows: Before:
After:
Programmer’s Notepad had previously executed a Replacement Expression successfully on 650+ items in that same file, just as i wanted without error. However, when I first opened the file, i was seeing this error. I enabled (tested), then disabled the “Allow Backslash Expression” option at that time, which seemed to “fix” the error, but that old-trick didn’t work this time. Looking through the code, it must have “went away” for the bulk of my work, i think until trying this particular expression which, btw– i realized, even if successful, wasn’t quite what i was going for– but, you know– win some lose some, eh? (a lot of fooling around w/ regex, really– guess i enjoy wasting time… i dunno) heheh… anyway– I suspect, if i exit the app, and restart it– i’ll probably have more success– so, this isn’t a complaint, but just an FYI. best regards! -js EDIT: geez… i hope i edited that code correctly, to reflect what’s going on. note the double-reverse-solidus character which appeared (the unexpected result) in the “After” shot. NOTE: — here, it doesn’t appear as PNpad has removed any chars, which was the plan, however– as i mentioned, when i first started, and i saw these reverse-solidus chars, it was removing, for example, instead of returning 1, it removed it, and went on w/ the rest of the expression. damn– too bad it’s so difficult to try to explain in a few short sentences, and many long sentences doesn’t help much, i guess. oh well! ‘least i’ve tried, eh? (1) sourceforge . net / projects / yui / |
| August 25, 2009 at 8:39 am #16725 | |
|
simon Key Master
|
Yes, it looks like there are a couple of bugs with the handling of escaped expressions and grouped expressions with the regular expressions. Could you please open an issue: http://code.google.com/p/pnotepad/issues/entry Thanks! |
| August 27, 2009 at 11:42 pm #16726 | |
|
fedoracore Member
|
okay. i want to help, so i’ll try to open an issue on this soon. coincidentally, i am about to try a regex operation, and i’ve selected ProsNpad for the job. Perhaps this will lead to something more meaningful in that “issue” entry. otherwise, i’ll do my best for creating a proper issue based on what i recall from the previous instance, as stated above. |
| August 31, 2009 at 1:42 pm #16727 | |
|
Nux Member
|
The expression “(return[ S]+ (return[ S]+ Also note that the third parentheses are non-capturing (so you cannot really use 3). In fact whatever is matched with “(?=S)” wouldn’t be in the match at all (i.e. for “return blah;}abc” the match would be “return blah;}” – without “a”). Nice regular expression reference is here: https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Global_Objects/RegExp |
You must be logged in to reply to this topic.
(})(?=S)ÂÂ