Skip to main content
Inspiring
Jun 18, 2025 1:36 PM UTC
Answered

GREP bracket remover.

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

Eugene TysonCorrect answer
Community Expert
Jun 18, 2025 1:37 PM UTC

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

 

Find

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

 

Change to

$1

6 replies

Eugene TysonCommunity ExpertCorrect answer
Community Expert
Jun 18, 2025 1:37 PM UTC

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

 

Find

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

 

Change to

$1

Translate
NikVetroAuthor
Inspiring
Jun 18, 2025 1:45 PM UTC

What does  "$1" mean in GREP language?

Translate
Community Expert
Jun 18, 2025 2:13 PM UTC

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 (...) 

 

Translate