Ask Your Question

Find replace a search term by partially formatted text?

asked 2018-06-19 15:26:33 +0100

mdm gravatar image

I wonder if it's possible to bulk replace the non-formatted formula for carbon dioxide with the formatted one (subscript 2). Something tells me it's impossible to replace search terms only formatting a part of them (in this case '2' > subscript 2).

I guess I have to restrict the search term to just '2' and walk through all instances of '2' through the 'next' button, replacing the 2's at each found instance of 'CO2'?

edit retag flag offensive close merge delete


In this specific case, just use Unicode Character 'SUBSCRIPT TWO' (U+2082) as the replacement.

Mike Kaganski gravatar imageMike Kaganski ( 2018-06-19 15:39:42 +0100 )edit

2 Answers

Sort by » oldest newest most voted

answered 2018-06-19 15:43:57 +0100

Actually, the problem here is to create a correct regular expression that would have only the "2" as the search result, and everything else just as (negative)? look-ahead/behind assertions. Like (?<=\bCO)2\b.

edit flag offensive delete link more

answered 2018-06-19 15:44:32 +0100

RGB-es gravatar image

You can select all the "2" after CO with the help of Regular Expressions.

On the full S&R tool (Ctrl H) check "regular expressions" under "more options" and search for


This expression will only pick the "2", ignoring the CO or any other combination with a "2" on it. Then you can either format the 2 as suffix or replace it by ₂ as @Mike Kaganski suggest.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-06-19 15:26:33 +0100

Seen: 20 times

Last updated: Jun 19 '18