Bob Sawyer wrote:

 >   preg_match("'<$itemtag url=(.*?) />'si")

What you are asking here is everything after url= till the closing />.   
(Note that the ? is useless here.)


 >The regex above gives me:
 >
 >   url="foo.com" length="12345" type="audio/mpeg"

This is exactly what you asked for.


 >However, all I want is the contents of the URL attribute:
 >
 >   foo.com
 >
 >How do I write the regex above to do that?

You have to confine the regex to the enclosing double quotes:

preg_match("'<$itemtag +url=\"([^\"]*)\"'si")

I replaced the general .* with [^\"]*, because perl regexs are greedy, 
i.e. it will match as *much* as possible.  IOW the match \".*\" in your 
example would match   <<foo.com" length="12345" type="audio/mpeg>>, i.e. 
everything from the first quote on the line *till the last*.  IOW you 
have to exclude double quotes from being matched: hence  \"[^\"]*\"

Note also that I dropped the match for />, as you may have other 
attributes following the url="...", and that this regex will only match 
if the url="..." is the first attribute.

Rgds
Carl



[Non-text portions of this message have been removed]



Community email addresses:
  Post message: [email protected]
  Subscribe:    [EMAIL PROTECTED]
  Unsubscribe:  [EMAIL PROTECTED]
  List owner:   [EMAIL PROTECTED]

Shortcut URL to this page:
  http://groups.yahoo.com/group/php-list 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/php-list/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to