Regex to match only the first tag

tachra

New Member
I am trying to write a regex to find a selection in one long string of xml, and pull out the first instance of a tag it finds.My current code (which pulls out every match): \[code\](<action>(.*?)</action>)\[/code\]Sample code:\[code\]<request guid="58004a1e-0c32-4002-a101-59fc28af5836"><action>Sample/Action</action><date>"7/12/12"</date>\[/code\]I have tried using multiple ways I have found to either match the first instance and disregard everything else, check and make sure there is no match before the current match, set it to match exactly one, etc. but they all return two matches. I am unable to set the regex to look for a particular leading or trailing tag as those can change.
 
Back
Top