N
NvrBst
I want to use the .replace() method with the regular expression /^ %VAR
% =,($|&)/. The following DOESN'T replace the "^default.aspx=,($|&)"
regular expression with "":
---------------------------------
myStringVar = myStringVar.replace("^" + iName + "=,($|&)", "");
---------------------------------
The following DOES replace it though:
---------------------------------
var match = myStringVar.match("^" + iName + "=,($|&)");
if(match != null && match.length > 0) myStringVar =
myStringVar.replace(match[0], "");
---------------------------------
Am I using the replace method wrong? The following DOES work when
using the replace method for me:
---------------------------------
myStringVar = myStringVar.replace(/^default.aspx=,($|&)/, "");
---------------------------------
But I need to use the "iName" variable instead of "default.aspx".
Does replace not let me use strings as regular expressions
like .match() and .search()? Anyone know how I would get .replace()
to work the way I want it to? Reasion I'm curious is because the 2nd
method above takes about 2 seconds to complete on my machine when I
have a feeling the single ".replace()" would probably take 1/2 the
time.
Thanks
NB
% =,($|&)/. The following DOESN'T replace the "^default.aspx=,($|&)"
regular expression with "":
---------------------------------
myStringVar = myStringVar.replace("^" + iName + "=,($|&)", "");
---------------------------------
The following DOES replace it though:
---------------------------------
var match = myStringVar.match("^" + iName + "=,($|&)");
if(match != null && match.length > 0) myStringVar =
myStringVar.replace(match[0], "");
---------------------------------
Am I using the replace method wrong? The following DOES work when
using the replace method for me:
---------------------------------
myStringVar = myStringVar.replace(/^default.aspx=,($|&)/, "");
---------------------------------
But I need to use the "iName" variable instead of "default.aspx".
Does replace not let me use strings as regular expressions
like .match() and .search()? Anyone know how I would get .replace()
to work the way I want it to? Reasion I'm curious is because the 2nd
method above takes about 2 seconds to complete on my machine when I
have a feeling the single ".replace()" would probably take 1/2 the
time.
Thanks
NB