Reputation: 3100
I am trying to use http://www.regexr.com/ to create a regular expression.
Basically I am looking to replace something that matches <Openings>any other tags/text</Openings>
<Openings><opening><item><x>3</x><y>3</y><width>10.5</width><height>13.5</height><type>rectangle</type><clipX>0</clipX><clipY>0</clipY><imgsrc></imgsrc></item></opening></Openings>
I started with ([\<Openings\>])\w+
(http://regexr.com/393mv ) but it seems to be matching too many things. Right now that regular expression should only match <Openings>
.
Upvotes: 1
Views: 36
Reputation: 174766
Regex to match the whole Openings tag is,
<Openings>.*?<\/Openings>
If you want to capture the contents inside the Openings tag then try the below,
<Openings>(.*?)<\/Openings>
Upvotes: 1
Reputation: 63424
([\<Openings\>])\w+
The brackets mean "Match any character in this". You should use
(\<Openings\>)\w+
which matches specifically "<Openings>"
plus one or more word characters.
Upvotes: 0