/<\/?(?!p)[\s\S]*?>/ig what about the last ">" ? you tested it as '</p>'.match(/<\/?(?!p)/) but it should be '</p>'.match(/<\/?(?!p)>/) If the last ">" weren't there you were right. But now it should account for the final ">" as well isn't it? Cheers, Volkan. ---------- Forwarded message ---------- From: Jeffery To <jeffery.to at gmx.net> Date: Thu, 10 Mar 2005 04:50:07 -0500 Subject: Re: [thelist] Regular Expression - Is it a bug or am I missing something very obvious? To: "thelist at lists.evolt.org" <thelist at lists.evolt.org> It's matching what you're telling it to match: '</p>'.match(/<\/?(?!p)/) returns '<' because the string '<' contains the character '<', zero occurrences of the character '/' and is not followed by the character 'p' in the source string. (It is followed by the character '/'.) HTH, Jeff VOLKAN ÖZÇELİK wrote: > Hi Community, hi RegExp lovers! > > Regarding the following js reg exp. > > /<\/?(?!(p))/ig; (It's a simplified version of what I'm working on) > > I think what it is supposed to do is: > > 1. match character < literally > 2. match craracter / literally (zero or one times) > 3. If there is a p immediately after do not match anything, just > rollback (i.e. negative lookahead) > > so the code below > > var strTest1 = "</p>"; > var regEx1 = /<\/?(?!(p))/ig; > strTest1 = strTest1.replace(regEx1,"") > alert(strTest1); > > should alert "</p>". > Well it doesn't. It alerts "p/>". Which means that it has found a match. > > I need to swap things around to make it work: > > var strTest2 = "</p>"; > regEx2 = /<(?!(\/p|p))/ig; > strTest2 = strTest2.replace(regEx2,"") > alert(strTest2); > > but why on earth do I need to make things unnecessarily complicated ?! > The first one should work at least according to my humble logic! > > Is it a bug? Or am I missing a really simple thing? > > Please help me before I split this PC with an axe. > > TIA, > Volkan. -- * * Please support the community that supports you. * * http://evolt.org/help_support_evolt/ For unsubscribe and other options, including the Tip Harvester and archives of thelist go to: http://lists.evolt.org Workers of the Web, evolt !