Hello, I am new to this group. I am utterly frustrated with this issue. Here is the issue:

The entire variable is replaced when attempting to replace only periods - it replaces the whole word instead of just the period(s).

This is the code that is giving me the problem.

myString = new String(rs('OVR_Insured'))
rExp = /./gi;
newString = new String ("?")
OVR_Insured = myString.replace(rExp, newString)

There are no syntax errors or anything and, the same code, but with a dash or a comma (instead of a period) between the slashes, works perfectly. Ex.

myString = new String(rs('OVR_Insured'))
rExp = /-/gi;
newString = new String ("?")
OVR_Insured = myString.replace(rExp, newString)

The above works perfectly in terms of replacing all instances of "-" with "?"

I think a period somehow represents the whole variable instead of the server taking it literally and a "period represents a period".

All I am trying to do is remove all periods from a variable. If someone can show me a working example of this being accomplished in Jscript, I would be forever greatful and probably avoid getting fired. :)

Thank You,
Scott

I have not tried this myself, but why create the periods as a string, instead make it a CONST Char datatype.

Or use the Regex Class to assist.

Not sure that helps...

Scott,

The reason you're getting this is because in Regular Expression syntax, '.' matches any single character. To match litteral dots, you need to escape it (\.). So, your search would look like:

var rExp = /\./gi

Josh

This article has been dead for over six months. Start a new discussion instead.