R
Rob
I've just about beat my brains all the way out on this one. Is anyone
up to the amazingly ridiculous challenge of figuring this one out?
Here's the code, followed by my question:
<script type="text/javascript">
function readCookie(valuename)
{
var the_cookie = document.cookie;
the_cookie = unescape(the_cookie);
var nameAndValue = new RegExp( valuename + "=[a-z0-9]*" );
the_cookie = the_cookie.match( nameAndValue );
// so far so good, I now have "name=value" stored in the_cookie
var onlyEqualsAndValue = new RegExp( "=[a-z]*" );
the_cookie = the_cookie.match( onlyEqualsAndValue );
alert(the_cookie);
}
</script>
Why doesn't the second call to match() give me just "=value"? The
first regex works flawlessly, but the second one fails for no reason
that I can see--and in fact the alert only pops up if I don't attempt
to make the second call to match(). WTF?
TIA,
Rob
up to the amazingly ridiculous challenge of figuring this one out?
Here's the code, followed by my question:
<script type="text/javascript">
function readCookie(valuename)
{
var the_cookie = document.cookie;
the_cookie = unescape(the_cookie);
var nameAndValue = new RegExp( valuename + "=[a-z0-9]*" );
the_cookie = the_cookie.match( nameAndValue );
// so far so good, I now have "name=value" stored in the_cookie
var onlyEqualsAndValue = new RegExp( "=[a-z]*" );
the_cookie = the_cookie.match( onlyEqualsAndValue );
alert(the_cookie);
}
</script>
Why doesn't the second call to match() give me just "=value"? The
first regex works flawlessly, but the second one fails for no reason
that I can see--and in fact the alert only pops up if I don't attempt
to make the second call to match(). WTF?
TIA,
Rob