R
Ronald Fischer
I have a server-side JavaScript function returning a string.
I would like to test wheather or not the string contains the following pattern:
- an equal sign,
- followed by one or more characters which are neither an ampersand nor an
equal sign,
- followed by another equal sign.
That is: A return value of that function of
X=ABCY=DEF should match, but
X=ABC&Y=DEF should not match
This is what I came up with:
if(((/=[^&=]+=/).test(get_query_string())) != null)
{
// matches
}
else
{
// does not match
}
The problem is that the function matches too much. For example, if
get_query_string() returns "LANG=EN", it matches too, although the
string contains only a single equal sign!
Any idea of what could be wrong here?
Ronald
I would like to test wheather or not the string contains the following pattern:
- an equal sign,
- followed by one or more characters which are neither an ampersand nor an
equal sign,
- followed by another equal sign.
That is: A return value of that function of
X=ABCY=DEF should match, but
X=ABC&Y=DEF should not match
This is what I came up with:
if(((/=[^&=]+=/).test(get_query_string())) != null)
{
// matches
}
else
{
// does not match
}
The problem is that the function matches too much. For example, if
get_query_string() returns "LANG=EN", it matches too, although the
string contains only a single equal sign!
Any idea of what could be wrong here?
Ronald