Search and Replace, regexp question
Hello,
I have several XML files in my project. I have many many tags that look like this, and want to get rid of the debug attribute:
I can't figure out how to use regular expressions in the search and replace dialog to get rid of the debug attributes. I check the regexp checkbox and try putting something like
Text to find: debug*/>
Replace with: />]]>
It doesn't work. How do I use regular expressions in search and replace?
Please sign in to leave a comment.
I think you're confusing regular expressions with glob-style matching.
In a regular expression, the * operator is a qualifier for the group
preceding it. In your case, debug*/> would match debug/>, and
debugggg/>, but not debug=""/>.
I think a quick fix for your problem would be to use:
debug=".*?"
The . means "any character", and the ? means "match the shortest
possible sequence" (otherwise it would match the longest possible
sequence inside quotation marks, like everything from xx to yy in:
debug="xx"/>]]>
With the upcoming IDEA 5.0, you can use Structural Search and Replace
with XML, which would make this operation a little bit easier and more
accurate.
Darrel Riekhof wrote:
The pattern for any char is .* thus your "Text to find" would need to be : debug.*/>
From "Help -> Help Topics -> Navigation & Search -> Replace Options" :
For more information on regular expressions and their syntax,
please, refer to Javadoc for java.util.regex (Java SDK 1.4).
Thanks for explaining it. It works and I'm happy now. :)