Regular expressions: fetch certain xml attributes from a specific xml element

rogue1239

New Member
I have a document with the following format:\[code\]<scheme attr1="lorem" attr2="ipsum" global-test="text goes here" global-attr2="second text goes here"></scheme>\[/code\]I want to use a regular expression to extract all the attributes that match \[code\]global-(.*)\[/code\].It can also only match on the "scheme" element, so using a simple regular expression like \[code\](global-([^=]*)="([^"]*)")+\[/code\] is not an option. I tried the following regular expression:\[code\]<scheme.*([\s]+global-([^=]*)="([^"]*)")+\[/code\]But this will only match on "global-attr2", and will see the other global attributes as part of the .* selector. Making the * selector on .* lazy also doesn't seem to help.And I know that getting data from an XML document with regular expressions isn't a good practice, but this script is for a preprocessor. It modifies the XML before parsing it.
 
Back
Top