Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replace Reg. Express: Part I

Status
Not open for further replies.

TheConeHead

Programmer
Joined
Aug 14, 2002
Messages
2,106
Location
US
How do I remove periods (.) I tried:

pnumber = pnumber.replace(/./g,"");

But it removed everything....

[conehead]
 
neveermind - I got it:

pnumber = pnumber.replace(/\./g,"");

[conehead]
 
Just to add for clarity - the reason that it did not work before is because the period (.) is a regexp universal character that matches anything other than a newline character (\n). I'm guessing that since you had declared your regexp to be global (by the g on the end of the regexp) that your entire string was being replaced by an empty string ("") because the period was matching every character in the string.

-kaht

[small] <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <B> <P> <.</B>[/small]
[banghead] [small](He's back)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top