views:

148

answers:

3

I've been stuck on an interesting (IE: mind numbing) question for the past few hours.

I've been trying to parse operators with regex:

([<>]=?|[!=]=)

The ones that I want are: <= >= < > == !=

== and != matches great. But all the ones having to do with < or > doesn't on my Drupal site, even though they should theoretically work.

What I ended up doing is this: .replace(/more than/ig, ">")

And in the text write "more than" where I would write >, and it works! Matches perfectly and everything...

This is really really silly, but I cannot think of a reason why this issue would exist. I turned off all the filters in Drupal, and in Firebug just writing > normally looks like >, not escaped or anything.

I'm really confused and hope for enlightenment.

Thanks.

+5  A: 

Could something be changing your source material into entities?

&gt; vs > 

&lt; vs <
DGM
Thanks yep that's it, and to molf as well.
Jourkey
@DGM, check out my edit; was that what you meant?
Alan Moore
Well, not exactly but it conveys the same idea. I was just showing one in code mode and one without to demonstrate that they looked the same.
DGM
+3  A: 

Did you try actually matching the escaped version?

Firebug will not show the content escaped, i.e. it will not display > as entities (&gt;) even though they are (view the source of this page to check that). It seems very likely that it is the problem.

molf
Yeah I did not know that about Firebug. Thank you very much.
Jourkey
A: 
((&lt;|&gt;)=?|[!=]=)
Brad Gilbert