Quotes in regular expressions

From: Date: Thu, 21 Aug 2003 16:03:02 +0000
Subject: Quotes in regular expressions
Groups: php.general 
Request: Send a blank email to php-general+get-160306@lists.php.net to get a copy of this message
Lets say I'm trying to extract some data from an HTML document. I want to get the values of the 'src' attributes of various tags. For example- <img src="http://www.yahoo.com"> here's the pattern I've been trying- /\bsrc=(['|"])[^\\1]*[\\1]/im Basically, match the 'src=' followed by some type of quote, followed by stuff that's not the quote originally matched, followed by the same quote. But, obviously, I can't run this, because the quotes in the pattern close off the string I'm trying to create. Are there ways of working with quotes? Or do I need to do something stupid like run it twice with either kind of quotes? Or perhaps there's a better way?? Thanks- Thaddeus

« previous php.general (#160306) next »