Escape .(dot) in a Regular Expression

Discussion in 'Javascript' started by bharath_r, Nov 17, 2008.

  1. bharath_r

    bharath_r Guest

    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
     
    bharath_r, Nov 17, 2008
    #1
    1. Advertising

  2. bharath_r

    Evertjan. Guest

    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)
     
    Evertjan., Nov 17, 2008
    #2
    1. Advertising

  3. 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
     
    Thomas 'PointedEars' Lahn, Nov 17, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VSK
    Replies:
    2
    Views:
    2,379
  2. aefxx
    Replies:
    1
    Views:
    616
    Virgil Green
    Dec 17, 2004
  3. Samuël van Laere

    To dot or not to dot?

    Samuël van Laere, Oct 16, 2003, in forum: HTML
    Replies:
    8
    Views:
    459
    Samuël van Laere
    Oct 16, 2003
  4. Replies:
    6
    Views:
    287
    Thomas 'PointedEars' Lahn
    Dec 12, 2005
  5. lev
    Replies:
    9
    Views:
    143
Loading...

Share This Page