I'm trying to check if a string contains specific letters like E
or F
, with the following code
/^(F?)/.test('E22')
The problem is that it returns true
, when it should return false
. And what bothers me most, is that testing the regex at regexpal.com, goes perfect, but when applied... wrong.
Any idea what goes wrong?
http://jsfiddle.net/alleks/CykQv/
UPDATE
I have explained my self wrong. I do individual checks, in different cases. So, in specific cases I need to see if the string contains an E
, and in others, if contains an F
//Case1
if (/^(F?)/.test(stringContainsE)) ....
//Case2
if (/^(F?)/.test(stringContainsF)) ....
Update2
Both cases return TRUE when they shouldn't: http://jsfiddle.net/alleks/CykQv/2/