471,893 Members | 1,988 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,893 software developers and data experts.

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 30683
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
reply views Thread by YellowAndGreen | last post: by
reply views Thread by zermasroor | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.