SweatCoder
asked on
global replace with a variable
truncFilename = filename.substr(0,filename .lastIndex Of("."))
alert(urlPathToXdl.replace (/truncFil ename/g,es cape(trunc Filename)) )
the above replace does not work because "truncFilename" is a variable and not a string literal. if I change to:
alert(urlPathToXdl.replace (truncFile name,escap e(truncFil ename)))
...then the replace works but not globally (only replaces 1st instance).
How do I correctly specify the global replace?
alert(urlPathToXdl.replace
the above replace does not work because "truncFilename" is a variable and not a string literal. if I change to:
alert(urlPathToXdl.replace
...then the replace works but not globally (only replaces 1st instance).
How do I correctly specify the global replace?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.