Jourkey
Jourkey

Reputation: 34976

JS not accepting <> greater than or less than signs

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.

Upvotes: 1

Views: 2008

Answers (3)

Brad Gilbert
Brad Gilbert

Reputation: 34120

((&lt;|&gt;)=?|[!=]=)

Upvotes: 0

DGM
DGM

Reputation: 26979

Could something be changing your source material into entities?

&gt; vs > 

&lt; vs <

Upvotes: 6

molf
molf

Reputation: 74985

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.

Upvotes: 3

Related Questions