www.webdeveloper.com
Results 1 to 3 of 3

Thread: [RESOLVED] Help JavaScript Regex

  1. #1
    Join Date
    Jun 2007
    Location
    Tangerang, Banten
    Posts
    258

    resolved [RESOLVED] Help JavaScript Regex

    Help me please..
    Why this code does not works :
    Code:
    var pattern = new RegExp("\s\[x\]$");
    var gototext = document.getElementById(index).text.replace(pattern,"");
    while this code works :
    Code:
    var gototext = document.getElementById(index).text.replace(/\s\[x\]$/,"");
    I test it in firefox..
    Pattern that i need is : [x] in the end of string.

    Thanks for any help..
    To the people inside it will feel like an earthquake.
    That should knock out the Greco.
    And that's your exit strategy.

  2. #2
    Join Date
    Aug 2007
    Posts
    3,767
    When used as a string, you must use "\\s\\[x\\]$". \ denotes a special character in a string as well.
    Great wit and madness are near allied, and fine a line their bounds divide.

  3. #3
    Join Date
    Jun 2007
    Location
    Tangerang, Banten
    Posts
    258

    resolved Solved

    Yes.. i did not realized that..
    Thank you so much..
    To the people inside it will feel like an earthquake.
    That should knock out the Greco.
    And that's your exit strategy.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles