SilverAge Software
Search And Replace. For Windows.
Use Cases
How can I replace something within some tag?
Question
How can I replace something within some tag for e.g. if I want to replace
something within this tag <first> this is a test
</first>
I want the output which is <first></first>.
Answer
The solution is very simple. First, you have to match an opening tag:
\<tag_name[^\>]#\>
Here, [^\>]# matches any text after the tag name (attributes, values) until the closing > is reached.
Then, match tag inner text:
[^\<]#
which matches the tag inner text until the opening < is reached.
And the closing tag:
\<\/tag_name\>
The full search expression with () to store tags:
(\<tag_name[^\>]#\>)[^\<]#(\<\/tag_name\>)
Now, the replace expression:
\1something\2
- Type the search expression
(\<tag_name[^\>]#\>)[^\<]#(\<\/tag_name\>)in the Find What field. - Type the text that will replace the match in the Replace With field:
\1something\2.
To insert multiple lines of text, use the multiline editor by clicking the Replace With button. - Check the Regular Expressions box and uncheck the Force search only box.
- Click Replace.