Changing CO2 subscript using Find and Replace

Sally

New Member
Hello.

I'm working on report and need to change CO2 to subscript throughout. Can anyone point me in the direction of the best way to do this? I know it's probably using GREP but I've had a brain fart and just can't remember.

Many thanks in advance!
 
You need to use the Lookbehind in the GREP

So it looks behind - but doesn't include it in the search result.


GREP is case sensitive
so this will find

any 2 after co2 Co2 cO2 CO2

(?<=[c|C][o|O])2
Then you change the formating to subscript.

Alternatively - if you're using styles - you can insert the GREP style into the Paragraph Style. And then it will automatically update any text that is added.
 
You need to use the Lookbehind in the GREP

So it looks behind - but doesn't include it in the search result.


GREP is case sensitive
so this will find

any 2 after co2 Co2 cO2 CO2

(?<=[c|C][o|O])2
Then you change the formating to subscript.

Alternatively - if you're using styles - you can insert the GREP style into the Paragraph Style. And then it will automatically update any text that is added.
Perfect! Thank you so much!
 
For clarification the lookbehind is

(?<=)
And you insert whatever text you need in this to look for.

For example you could look for Euros.
(?<=€)

Then you need to qualify that with something to look for - usually currency is in digits (I don't know why I said usually, it's always..right?)

Anyway
(?<=€)
you need digits
you could do [0-9]
(?<=€)[0-9]

Or you could do a digit
\d

(?<=€)\d
looks for € followed by a digit
So it highlights €1 but only the first digit of €10 or €100 or €1000.00

You need to expand the digit search
+ symbol is needed
(?<=€)\d+
Finds
Looks for € followed by €1111111111111 etc.

But if your text says '€11111 was paid for by 100 people'
It will find the text all the way up to the 100
As the + symbol is infinite - keep looking for digits.

So you need to shorten the range with a
?
(?<=€)\d+?

Now you are looking for € followed by as many digits in a cluster
\d+?

no you need to find the cents
which would be
\.\d\d

\. the backlash acts as an escape - the . on it's own means any character
to look for a full stop you need to escape the GREP code for any character
\ escape . any character
\. looks for a full stop

No it looks like this
(?<=€)\d+?\.\d\d

But a slightly neater way to look for 2 digits together is
\d{2}

\d is any digit and curly brackets {} will look for the number repeitiion
so {2} looks for two.

Now you can find any text that has a Euro symbol (but not find the euro symbol itself
It's looking behind the \d for a €

(?<=€)\d+?\.\d{2}

And then it's looking for any digit up to as many as possible + in the shortest range ?
\. is a period (full stop)
\d{2} is two digits


That is a breakdown on how to do some GREP.
It's actually fantastic once you get into it.

You can do so much!
 
Back
Top