Search code examples
regexcoldfusioncoldfusion-9railo

ColdFusion - Regex to match SRC with single quotes


I have a simple regex line to extract the src="" value from an image tag:

<cfset variables.attrSrc = REMatch("(?i)src\s*=\s*""[^""]+", variables.myImageTag) />

<!--- REMatch("(?i)src\s*=\s*""[^""]+" --->

However, while this works great, it doesn't appear to be working with src='' attrubutes that display single quotes instead of double.

Ideally, I'd like it to work with both single quotes and double.

Any thoughts?

Thanks, Michael.


Solution

  • (?i)src\s*=\s*(""[^""]+""|'[^']+')