SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Jul 2006
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Regular Expressions and multiple matches

    Hi

    Isnt it possible to write a regular expression using javascript, to return more than one match? I have a string I want to do a match on and find all the image tags and return the value of the alt attribute.

    It finds the first match without a problem and I can get the value of the alt attribute but it seems to ignore the other tags even though I've specified the global and ignore-case flags on the regex object.

    I need to return the entire tag + the alt value of each img tag in the string but it stops after the first one =/

    Any ideas?
    Last edited by Andreas Håkansso; Jul 21, 2006 at 09:18.

  2. #2
    SitePoint Member
    Join Date
    Nov 2004
    Location
    compton
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You need to use the global switch :

    /YourRegExp/g

  3. #3
    SitePoint Member
    Join Date
    Jul 2006
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Like I said.. "I've specified the global + ignore-case flags"

  4. #4
    SitePoint Member
    Join Date
    Nov 2004
    Location
    compton
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    We'll need to see the code.


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
  •