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 13:45 Gabriel Gilini wrote: > Joe Nine wrote: >> stevewy(a)hotmail.com wrote: >>> I'm just trying to work out (if what I want is at all possible), a >>> regular expression that will search for and select (in a text editor >>> that supports regexps, like Notepad++) the word "onclick", then any >>> text at all, up to and including ">". >>> >>> I thought >>> >>> onclick*\> >>> >>> would work, but it doesn't. >>> >>> Basically it needs to Find the word onclick, then select all the text >>> up to >. Sort of like an extended search. >>> >>> The wildcard "*" symbol select "the previous token", not "all and >>> anything" like I am used to. >>> >>> What am I doing wrong? >> >> I don't know the right regexp but I do notice that you're making an >> assumption that the onclick is always going to be last, before the > >> character. It might not be. > > No, he isn't. Read his post again, he wants to match everything that > goes after the string "onclick" until the first appearance of ">". <… onclick="if (2 > 1) window.alert(42);">…</…> > What I have failed to understand is how the OP issue correlates with > Javascript. Add me. PointedEars -- Anyone who slaps a 'this page is best viewed with Browser X' label on a Web page appears to be yearning for the bad old days, before the Web, when you had very little chance of reading a document written on another computer, another word processor, or another network. -- Tim Berners-Lee
From: Joe Nine on 10 Jun 2010 13:58 Gabriel Gilini wrote: > Joe Nine wrote: >> stevewy(a)hotmail.com wrote: >>> I'm just trying to work out (if what I want is at all possible), a >>> regular expression that will search for and select (in a text editor >>> that supports regexps, like Notepad++) the word "onclick", then any >>> text at all, up to and including ">". >>> >>> I thought >>> >>> onclick*\> >>> >>> would work, but it doesn't. >>> >>> Basically it needs to Find the word onclick, then select all the text >>> up to >. Sort of like an extended search. >>> >>> The wildcard "*" symbol select "the previous token", not "all and >>> anything" like I am used to. >>> >>> What am I doing wrong? >>> >>> Steve >> >> I don't know the right regexp but I do notice that you're making an >> assumption that the onclick is always going to be last, before the > >> character. It might not be. > No, he isn't. Read his post again, he wants to match everything that > goes after the string "onclick" until the first appearance of ">". Yes technically that's what he said. I was reading between the lines and deducing that it's probably not what he wants. I suspect he wants the contents of the onclick string. Here's an example where he gets more than that. < ...onclick="something()" onmouseover="somethingelse()">
From: Gabriel Gilini on 10 Jun 2010 14:02 Thomas 'PointedEars' Lahn wrote: > Gabriel Gilini wrote: > >> Joe Nine wrote: >>> stevewy(a)hotmail.com wrote: >>>> I'm just trying to work out (if what I want is at all possible), a >>>> regular expression that will search for and select (in a text editor >>>> that supports regexps, like Notepad++) the word "onclick", then any >>>> text at all, up to and including ">". >>>> >>>> I thought >>>> >>>> onclick*\> >>>> >>>> would work, but it doesn't. >>>> >>>> Basically it needs to Find the word onclick, then select all the text >>>> up to >. Sort of like an extended search. >>>> >>>> The wildcard "*" symbol select "the previous token", not "all and >>>> anything" like I am used to. >>>> >>>> What am I doing wrong? >>> I don't know the right regexp but I do notice that you're making an >>> assumption that the onclick is always going to be last, before the > >>> character. It might not be. >> No, he isn't. Read his post again, he wants to match everything that >> goes after the string "onclick" until the first appearance of ">". > > <… onclick="if (2 > 1) window.alert(42);">…</…> Yes, I know that, given the context, that is a faulty request. I was just stating OP's request. The short answer would be: Don't.
From: Thomas 'PointedEars' Lahn on 10 Jun 2010 14:05 Gabriel Gilini wrote: > Thomas 'PointedEars' Lahn wrote: >> Gabriel Gilini wrote: >>> Joe Nine wrote: >>>> stevewy(a)hotmail.com wrote: >>>>> I'm just trying to work out (if what I want is at all possible), a >>>>> regular expression that will search for and select (in a text editor >>>>> that supports regexps, like Notepad++) the word "onclick", then any >>>>> text at all, up to and including ">". >>>>> [...] >>>>> >>>>> Basically it needs to Find the word onclick, then select all the text >>>>> up to >. Sort of like an extended search. >>>>> >>>>> The wildcard "*" symbol select "the previous token", not "all and >>>>> anything" like I am used to. >>>>> >>>>> What am I doing wrong? >>>> I don't know the right regexp but I do notice that you're making an >>>> assumption that the onclick is always going to be last, before the > >>>> character. It might not be. >>> No, he isn't. Read his post again, he wants to match everything that >>> goes after the string "onclick" until the first appearance of ">". >> >> <… onclick="if (2 > 1) window.alert(42);">…</…> > Yes, I know that, given the context, that is a faulty request. There is nothing faulty about this. > I was just stating OP's request. You have (mis)interpreted it in your favor. > The short answer would be: Don't. Nonsense. PointedEars -- Anyone who slaps a 'this page is best viewed with Browser X' label on a Web page appears to be yearning for the bad old days, before the Web, when you had very little chance of reading a document written on another computer, another word processor, or another network. -- Tim Berners-Lee
From: Gabriel Gilini on 10 Jun 2010 14:13
Thomas 'PointedEars' Lahn wrote: > Gabriel Gilini wrote: > >> Thomas 'PointedEars' Lahn wrote: >>> Gabriel Gilini wrote: >>>> Joe Nine wrote: >>>>> stevewy(a)hotmail.com wrote: >>>>>> I'm just trying to work out (if what I want is at all possible), a >>>>>> regular expression that will search for and select (in a text editor >>>>>> that supports regexps, like Notepad++) the word "onclick", then any >>>>>> text at all, up to and including ">". >>>>>> [...] >>>>>> >>>>>> Basically it needs to Find the word onclick, then select all the text >>>>>> up to >. Sort of like an extended search. >>>>>> >>>>>> The wildcard "*" symbol select "the previous token", not "all and >>>>>> anything" like I am used to. >>>>>> >>>>>> What am I doing wrong? >>>>> I don't know the right regexp but I do notice that you're making an >>>>> assumption that the onclick is always going to be last, before the > >>>>> character. It might not be. >>>> No, he isn't. Read his post again, he wants to match everything that >>>> goes after the string "onclick" until the first appearance of ">". >>> <… onclick="if (2 > 1) window.alert(42);">…</…> >> Yes, I know that, given the context, that is a faulty request. > > There is nothing faulty about this. I think you misunderstood me. What I tried to say is that trying to match everything after an onclick attribute up to the end of the opening tag with Regular Expressions in HTML isn't something that could be relied upon, as you so technically put in your reply to OP. >> I was just stating OP's request. > > You have (mis)interpreted it in your favor. I don't think so. | stevewy(a)hotmail.com wrote: | > I'm just trying to work out (if what I want is at all possible), a | > regular expression that will search for and select (in a text editor | > that supports regexps, like Notepad++) the word "onclick", then any | > text at all, up to and including ">". This is exactly what I said. >> The short answer would be: Don't. > > Nonsense. Now you're confusing me. Do you think that what OP is trying to accomplish with Regular Expressions should be done or not? |