Skip to main content
Inspiring
June 18, 2025
Answered

GREP bracket remover.

  • June 18, 2025
  • 1 reply
  • 380 views

Hi,

I have one more problem and i need GREP to help me.

I have document witn more that 760 pages and everywhere there is a number in brakets [1], [2], [3]

I want to select them all and remove the brakets and the space around it.

For example from _[_1_]_ i want to stay only _1_. And this to happend with single number and double number. 

 

Can you help me

Correct answer Eugene Tyson

I replied on the other thread but someone has moved it here

 

Find

\[\s*(\d+)\s*\]

 

Change to

$1

1 reply

Eugene TysonCommunity ExpertCorrect answer
Community Expert
June 18, 2025

I replied on the other thread but someone has moved it here

 

Find

\[\s*(\d+)\s*\]

 

Change to

$1

NikVetroAuthor
Inspiring
June 18, 2025

What does  "$1" mean in GREP language?

Community Expert
June 18, 2025

It's a 'Found' reference

so in the Find part  (\d+)

\d+ is any amount of digits and encased in brackets as (\d+) marks it as 'Found'

 

$1 is the first found instance so it inserts this 

 

For example you could have 

12.94 and for some reason want to reverse this to 94.12

 

You would find 2 of them encased in brackets referenced as $1 $2 

(\d+)\.(\d+)

and change to

$2.$1

 

Now the figures reverse position because it's marked in the expression as (...)