Results 1 to 3 of 3

Thread: Regular Expression Problem in ajaxtabs script?

  1. #1
    Join Date
    Aug 2006
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Regular Expression Problem in ajaxtabs script?

    1) Script Title: Ajax Tabs Content Script

    2) Script URL (on DD): httphttp://www.dynamicdrive.com/dynamicindex17/ajaxtabscontent/index.htm

    3) Describe problem: I am running visual studio .net and when I open the script the following line:

    var modifiedurl=ulistlink.getAttribute("href").replace(/^http:\/\/[^\/]+\//i, "http://"+window.location.hostname+"/")
    ---^
    looks like it doesn't properly escape things because the rest of the line looks like a comment after the two //'s. Is this just a flaw in the dev environment or should the regular expression be enclosed in quotes? Would it hurt to enclose it in quotes?

    Thanks!
    Gandalf

  2. #2
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by gandalf97 View Post
    var modifiedurl=ulistlink.getAttribute("href").replace(/^http:\/\/[^\/]+\//i, "http://"+window.location.hostname+"/")
    ---^
    looks like it doesn't properly escape things because the rest of the line looks like a comment after the two //'s. Is this just a flaw in the dev environment or should the regular expression be enclosed in quotes?
    The editor is flawed, failing to recognise a regular expression literal.

    Would it hurt to enclose it in quotes?
    Yes, you'd break the script. It could be rewritten to use string literals, but that seems an absurd measure to take. Complain to Microsoft: VS.NET was written after Internet Explorer supported regular expression literals so there's no excuse for not recognising them in a script context.
    Mike

  3. #3
    Join Date
    Aug 2006
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Mike,

    Thanks for the reply. I suspected what you said but wanted to check to be sure. Nice to know I am still somewhat sane.

    Regards,
    Gandalf

Bookmarks

Posting Permissions

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