I have an xml document which i am converting to html.
There is a tag in the xml called <datecreated></datecreated>, and the date is in the format "dd-mm-yyyy hh:mm:ss".
This tag occurs multiple times.
I nedd to changes the contents of the tag to display the date to US format
I.e. "mm-dd-yyyy hh:mm:ss"
As you can see below I can get the contents of the tag, but dont know how to swap the dd & mm data around.
<cfset html = objXmlUtil.fixCDATABug(xmlTransform(REReplace(trim(qXML.xmlData),"<datecreated>[\d\w\s:-]+</datecreated>","<datecreated>[]</datecreated>","ALL"), trim(qXSL.stylesheet))) />
Any help greatly appreciated.
<cfset html = objXmlUtil.fixCDATABug(xmlTransform(REReplace(trim(qXML.xmlData),"<datecreated>(\d+)-(\d+)([^<]*)</datecreated>","<datecreated>\2-\1\3</datecreated>","ALL"), trim(qXSL.stylesheet))) />
Brilliant shyam, thanks.
Could you possibly explain how the ([^<]*) part works?
Could you possibly explain how the ([^<]*) part works?
[^<] matches any character that is not a < which is the starting character of the tag termintator </datecreated> so, it essentially matches everything before </datecreated> which is after (\d+)-(\d+)