Page 1 of 1

Simultanious Find and Replace of Tag Pairs

Posted: Wed Jan 31, 2018 5:18 pm
by EmelineDehnReynolds
Hello Good People of Oxygen,

Is it possible to replace the opening and closing tag at the same time, i.e., change <p>[text]</p> to <item>[text]</item> in one fell swoop within a portion of the document? If so how?

I know I could replace the opening then the closing tags across the text by doing first <p> -> <item> and then </p> -> </item>, but since I'm only doing small chucks of text at a time this is quite time-intensive. I don't want to work with find & replace over the entire scope of the document because there are some <p>[text]</p> tag pairs I'd like to keep as they are.

Thank you,
Emeline Dehn-Reynolds

Re: Simultanious Find and Replace of Tag Pairs

Posted: Wed Jan 31, 2018 5:40 pm
by adrian
Hi,

If you specifically just want to change both tags of (basically rename) an element, you can right click on either of the start or end tags and pick Refactoring > Rename Element.... In the Rename dialog you can control if this will be done on just the current element, all its siblings or all elements with the same name in the entire document.

If you want to use the Find/Replace tool, you can use a regular expression.
Find: <p>(.*?)</p>
Replace with: <item>$1</item>
Options > [x] Regular expression
Basically $1 points to the 1st capturing group (first group of parenthesis).

If you have nested p elements it's a bit more complicated, but I expect this isn't the case.

Regards,
Adrian