Prev: FAQ Topic - Why doesn't the global variable "divId" always refer to the element with id="divId"? (2010-06-10)
Next: Dynamically Creating Checkboxes
From: Thomas 'PointedEars' Lahn on 10 Jun 2010 15:44 Stefan Weiss wrote: > Thomas 'PointedEars' Lahn wrote: >> Stefan Weiss wrote: >>> Thomas 'PointedEars' Lahn wrote: >>>> (a false positive for your suggestion has already been mentioned). >>> >>> A false positive for what? The OP wanted to match... >>> >>> | the word "onclick", then any text at all, up to and including ">". >>> >>> ...which is just what the proposed expressions do. [...] >> >> No, think again. > > I'm curious. Do you mean that "any text at all" should exclude the empty > string as an edge case? [...] I mean that it should include "any text" to begin with. Granted, the OP's request is ambiguous to a large degree, but I would not assume "any text" to exclude `>' characters. So if there is a correct answer to this "question" it should, IMO, be more like onclick.*> (Not that this would likely be overly useful, of course.) PointedEars -- var bugRiddenCrashPronePieceOfJunk = ( navigator.userAgent.indexOf('MSIE 5') != -1 && navigator.userAgent.indexOf('Mac') != -1 ) // Plone, register_function.js:16
From: Stefan Weiss on 10 Jun 2010 16:03 On 10/06/10 21:44, Thomas 'PointedEars' Lahn wrote: > Stefan Weiss wrote: >> Thomas 'PointedEars' Lahn wrote: >>> Stefan Weiss wrote: >>>> Thomas 'PointedEars' Lahn wrote: >>>>> (a false positive for your suggestion has already been mentioned). >>>> >>>> A false positive for what? The OP wanted to match... >>>> >>>> | the word "onclick", then any text at all, up to and including ">". >>>> >>>> ...which is just what the proposed expressions do. [...] >>> >>> No, think again. >> >> I'm curious. Do you mean that "any text at all" should exclude the empty >> string as an edge case? [...] > > I mean that it should include "any text" to begin with. Granted, the OP's > request is ambiguous to a large degree, but I would not assume "any text" to > exclude `>' characters. So if there is a correct answer to this "question" > it should, IMO, be more like > > onclick.*> > > (Not that this would likely be overly useful, of course.) So you assume that "any text _up_ _to_ ... >" means that ">" characters are allowed in the text. That's a bit of a stretch. But- I can't disprove it, and you got to write your "no, think again" line, so it's all good. -- stefan
From: stevewy on 11 Jun 2010 05:41 On 10 June, 17:52, Stefan Weiss <krewech...(a)gmail.com> wrote: > If the regular expressions used by Notepad++ are similar to those in > JavaScript, you could try > > onclick.*?> or onclick[^>]*> > Well, it seems onclick="[^"]*" matches what I want (which is up to the > symbol, but not including it as I erroneously stated in my original post), but unfortunately does not include newlines. To be comprehensive, it would need to include any newline characters between onclick and the " symbol. So, it needs to select from onclick, all the way through the onclick statement till it finds the closing " mark. Across several lines if necessary. The reason I am needing this rather odd thing done, is that at work I deal with putting client-side validation into questionnaires, that are churned out by a survey application. The client-side validation relies, of course, on Javascript and has a lot of onClick statements. Later on in the life-cycle of the questionnaire, the validation needs to be stripped out. I am using Notepad++ that accommodates regexps in its find & replace feature. Being that onClick statements are of the form onClick=" [JS statements] " and each onClick is placed inside a form element tag of the HTML (like <INPUT>), I thought it would save time to use the find & replace feature of Notepad++ to select onClick statements and replace them with nothing, thus removing them. I realise, Thomas, that this is more a regexp query and not exclusively Javascript, although I am using it in a JS task. Does this help in figuring out the regexp I would need to accomplish this? At the moment, I am "so near and yet so far".... Steve
From: stevewy on 11 Jun 2010 06:39 Given the extra information supplied above, I did a more targeted Google search about my problem, and found this article: http://blog.microugly.com/2009/10/notepad-linebreaks-in-regular.html, which would indicate Notepad++ does not have very good support of regular expressions anyway. Other text editors have an option to specify whether "." includes newlines or not, but Notepad does not. And so, other than following the tip supplied in the article, it does not seem very likely that a regexp could be found to accomplish exactly what I need, not in Notepad++ at any rate. Anyway, thank you for the responses supplied to my initial query. Steve
From: SAM on 11 Jun 2010 06:55
Le 6/11/10 11:41 AM, stevewy(a)hotmail.com a �crit : > On 10 June, 17:52, Stefan Weiss <krewech...(a)gmail.com> wrote: > >> If the regular expressions used by Notepad++ are similar to those in >> JavaScript, you could try >> >> onclick.*?> or onclick[^>]*> >> > Well, it seems onclick="[^"]*" matches what I want (which is up to the >> symbol, but not including it as I erroneously stated in my original > post), but unfortunately does not include newlines. maybe : onclick="([^"]|\s)*" > I am using Notepad++ that accommodates regexps in > its find & replace feature. Don't know NotePad, sorry. > Being that onClick statements are of the form onClick=" [JS > statements] " and each onClick is placed inside a form element tag > of the HTML (like <INPUT>), I thought it would save time to use the > find & replace feature of Notepad++ to select onClick statements and > replace them with nothing, thus removing them. search : (onclick=")([^"]|\s)* replace : \1" or ? $1" -- sm |