Reputation: 27114
I have this sample string :
≪! [If Gte Mso 9]>≪Xml> ≪Br /> ≪O:Office Document Settings> ≪Br /> ≪O:Allow Png/> ≪Br /> ≪/O:Off...
And I would like to target specifically anything that begins in an "≪" and ends in a ">", and replace it with no-space "".
Been using Rubular, but I'm having a tricky time learning how to set this one up.
Any idaes?
Upvotes: 1
Views: 165
Reputation: 19145
It sure looks like you're trying to parse XML with regular expressions, which is a very difficult and fragile way to extract the data you need from that document.
You might be better off parsing it and selecting the information you need using XPath or DOM.
Upvotes: 0
Reputation: 643
Just a helpful hint, I use Rubular to help with regex writing a debugging.
Upvotes: 0
Reputation: 336098
result = subject.gsub(/≪[^>]*>/, '')
should do the trick.
[^>]*
means: Match any number of characters except >
.
Upvotes: 2