www.webdeveloper.com
Results 1 to 2 of 2

Thread: Javascript regular expression

  1. #1
    Join Date
    Jan 2010
    Posts
    1

    Javascript regular expression

    Hi,
    I have to parse a variable in the form of "1.|1=Site_Name=domain.tld=1" using regular expression as domain.tld will change and might also contain numbers like 1domain.tld.
    I have to get the domain.tld name only.

    I am trying to test the following code but it give me a null value.
    var test = /([0-9a-z]+\.[a-z]+/i.exec("1.|1=Site_Name=domain.tld);
    document.write (test);

    Appreciate if any one can help.

    Thanks

  2. #2
    Join Date
    Feb 2006
    Posts
    2,927
    Get rid of the parentheses in the Rx and close the quoted string.
    Code:
    alert(/[0-9a-z]+\.[a-z]+/i.exec("1.|1=Site_Name=1domain.tld").toString());

Thread Information

Users Browsing this Thread

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

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