I'm fuddling my way through using regular expressions in notepad++ with some .xml files, and may have gotten a little over my head.

I'm currently trying to search for anything that starts with:

<text id="name">Timer</text>   (where "Timer" is a random word\s)

and replace with

<text id="name">Timer</text><text id="MyRule">1.rule</text> 

1.rule would be used in all follow up instances of the search, the only random factor is the word between the id=name and the close of the text.

Another Example would be:

<text id="name">start up changes</text>

and i'm looking to replace to

 <text id="name">start up changes</text><text id="MyRule">1.rule</text>

Is there a simple regular expression that can find these random word or words, and then apply my changes after that expression. Any help would be greatly appreciated.

2 Answers 2


Karan's case will work. However, it's also a bit risky -- you'll also get replacements for the following:

<text id="Spatula">Um, how about kitchen utensils for $500, Alex?</text>
<text rex="a" expl="something" other_att="1">"Blasphemy!" he shouted, as he ran to the gondola.</text>

If you only want to catch those instances of <text> tags that only have id="name" attributes, and your file might have other content, then be specific:


(<text id="name">.*?</text>)


\1<text id="MyRule">1.rule</text>


If your sample content is intended to be XML or HTML, be aware that id values are supposed to be unique.


I don't have access to NotePad++ right now to double-check, but try the following:

Search: (<text.*?/text>)

Replace: \1<text id="MyRule">1.rule</text>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .