SilverAge Software

Search and Replace. Edit. Transform.

Use Cases

How can I find and replace text inside a tag?


How can I find text inside some tag and replace it with some other text? 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> something </first>.


The solution is very simple. First, you have to match an opening tag:


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:


The full search expression with () to store tags:


Now, the replace expression:

  1. Type the search expression (\<tag_name[^\>]#\>)[^\<]#(\<\/tag_name\>) in the Find What field.
  2. 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.
  3. Check the Regular Expressions box and uncheck the Force search only box.
  4. Click Replace.