Skip to main content
noob1212121
Known Participant
October 19, 2022
Answered

Forgive my ignorance in Grep but...

  • October 19, 2022
  • 3 replies
  • 426 views

how do you search and remove numbers like dd.dd where the second digit string can be one or two in size? For example 

18.55

or 

18.5

This topic has been closed for replies.
Correct answer m1b

Grep:

 

(\b\d{2})\.\d{1,2}\b

 

Change to:

$1

- Mark

 

Edit: didn't read the question right at first!

3 replies

Loic.Aigon
Legend
October 19, 2022

Don't apologize, GREP is all but an easy subject (it actually becomes easier with a lot of practice). What matters is to keep learning 😉

Also don't hesitate in taking advantage of the GREP F/C dialog within InDesign and the shortcuts the dialog offers (see @ button):

Then you can copy-paste supplied code as a starter.

FWIW

Loic

Community Expert
October 19, 2022

You want to go from 18.55

or 18.5

to 18

???

 

\d+\K\.\d{1,2}

 

m1b
Community Expert
Community Expert
October 19, 2022

@Eugene Tyson, that will also match part of longer digit strings, eg. in "1234.1234" it will match ".12". ( I did the same as you at first and at least you read the question correctly!) - Mark

Community Expert
October 19, 2022

Oh silly me I didn't try with longer string. Only with sample provided and it worked for me. 

But perhaps it was too open ended. 

 

Nice work on the GREP - I would have gotten there. 

I don't use much but know a little to help out from time to time - usually there is a much neater way to do things than the way I approach them.

 

Thanks

 

m1b
Community Expert
m1bCommunity ExpertCorrect answer
Community Expert
October 19, 2022

Grep:

 

(\b\d{2})\.\d{1,2}\b

 

Change to:

$1

- Mark

 

Edit: didn't read the question right at first!