www.webdeveloper.com
Results 1 to 3 of 3

Thread: [RESOLVED] Help JavaScript Regex

Hybrid View

  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..

  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.

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

    resolved Solved

    Yes.. i did not realized that..
    Thank you so much..

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