I am trying to convert a ColdFusion website to PHP using regex. I haven't found something to do it so I do it myself.
Lucky me, the coldfusion website is basic in term of programmation and regex can do the job.
However, I am stuck somewhere. How can I extract something like this ?
- <cfset mailfrom="hey">
- <cfset mailfrom='hey'>
- <cfset mailfrom=hey>
- <cfset mailfrom = hey>
- <cfset mailfrom="<hey>">
I did try the following pattern :
preg_match_all('/<cfset (.*)( )=(| |\'|")(.*)(|\'|")>/iU', $this->Content, $customTags, PREG_SET_ORDER);
It work sometime, sometime it don't. My ColdFusion code may be on 1 line or 1000 lines. So sometime you'll see something like this <cfset mailfrom="hey"><cfset fdsfsd="3333">
As soon as I know the full string (<cfset mailfrom="hey">
) and what to replace with ($mailfrom = "hey";
) I would be able to parse it without problem so this mean the regex has to give me at least the variable name and value.
Thanks.
EDIT :
I use this :
preg_match_all('/<cfparam\s*([^>]*)\s*\/?>/i', $this->Content, $customTags, PREG_SET_ORDER);
To match <cfparam name="" default="">. I guess I could do it the same way but parse(.) = (.) (Var = value)
But the problem here is this regex cannot match < and > in the value zone.