View Full Version : RegExp failing in Firefox

02-02-2010, 09:21 PM
I'm using a script that searches a string for specific text and uses the match() function to determine how many times that string appears within another string. Specifically I want to find out how many lines of text have the inline CSS "color:#00FF00;"

Using the line str.match(/#00FF00/gi); seems to work fine in IE, but will not return any results in Firefox. Is there an error in my RegExp, or does Firefox just have an issue with searching for hex color codes? If I replace the script to search for a word, like "green" instead of the color code, it works on both browsers, but the default CSS color for "green" is not the color I want to use for the displayed text.

02-02-2010, 09:40 PM
a little update to my issue, which just makes this even more frustrating...
if the color code is in the string outside the CSS code, the RegExp finds it fine, it's only when I have it listed as inline CSS style="color:#00FF00;" Firefox can't find it.

02-02-2010, 09:44 PM
Ok...nvm... seems Firefox is changing the hex code to a rgb value...
so basically I need to write it as str.match(/rgb\(0, 255, 0\)/gi); when running the page under Firefox...