I'm currently writing a parser for ColdFusion code. I'm using a regex (in c#) to extract the name datasource attribute of the cfquery tag.
For the time being the regex is the following
<cfquery\s.*datasource\s*=\s*(?:'|")(.*)(?:'|")
it works well for strings like
<cfquery datasource="myDS"
or
<cfquery datasource='myDS'
But it gets crazy when parsing strings like
<cfquery datasource="#GetSourceName('myDS')#"
Obviously the part of the regex (?:'|") is the cause. Is there a way to only match single quote when the first match was a single quote? And only match the double quote when the first match was a double quote?
Thanks in advance!