469,273 Members | 1,827 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,273 developers. It's quick & easy.

Escape .(dot) in a Regular Expression

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
Nov 17 '08 #1
2 29849
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

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Nov 17 '08 #2
bharath_r wrote:
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
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Nov 17 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by M Wells | last post: by
3 posts views Thread by EFP | last post: by
19 posts views Thread by Tom Deco | last post: by
3 posts views Thread by Henrik Dahl | last post: by
11 posts views Thread by Dimitris Georgakopuolos | last post: by
18 posts views Thread by Lit | last post: by
1 post views Thread by NvrBst | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.