Thread: RegExp trouble

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2008
    Posts
    2
    Rep Power
    0

    Exclamation RegExp trouble


    I have to math an URL in an href link that can have single or double quote or not.

    With this example

    /href=(\"|\')(myurl|)/

    the only match i have are:

    href="myurl
    and
    href='myurl

    but not

    href=myurl
    how i can make a regexp that match this type of code?


    Thank you all...
  2. #2
  3. Lord of the Dance
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2003
    Posts
    3,648
    Rep Power
    1945
    the ? modifier can be used to tell something can exists zero or one time.

    this should work:
    /href=(\"|\')?(myurl|)/
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2008
    Posts
    2
    Rep Power
    0
    It works! Thank you very much!

IMN logo majestic logo threadwatch logo seochat tools logo