Escape .(dot) in a Regular Expression

B

bharath_r

Hi,

I would like to know how can i escape a .(dot) in a regular expression
in javascript. I tried using 'backslash' to escape the 'dot' but its
not working. By default a 'dot' takes any character entered. I want to
escape it.

Thanks
Bharath
 
E

Evertjan.

bharath_r wrote on 17 nov 2008 in comp.lang.javascript:
I would like to know how can i escape a .(dot) in a regular expression
in javascript. I tried using 'backslash' to escape the 'dot' but its
not working. By default a 'dot' takes any character entered. I want to
escape it.

\. is working
 
T

Thomas 'PointedEars' Lahn

bharath_r said:
I would like to know how can i escape a .(dot) in a regular expression
in javascript. I tried using 'backslash' to escape the 'dot' but its
not working. By default a 'dot' takes any character entered. I want to
escape it.

You need either to escape the backslash in the string value that you are
passing or you must pass a RegExp literal instead.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top