Reputation: 1935
How can I remove numbers within brackets only? For example, I have the following text:
This is 14 April [988] text..
I would like to remove the [988]
and leave 14
intact.
What i've tried so far:
sed 's@\[[0-9]\]@@g'
Upvotes: 1
Views: 356
Reputation:
You need to enable repeating (multiple) numerical characters in order to get this work - as it stands, your regex will remove only single-digit numbers. If you want numbers composed of at least one (one or more) numerical characters, try
sed -E 's/\[[0-9]+\]//g'
Upvotes: 3
Reputation: 784958
You can use:
On Mac:
sed -E 's@\[[0-9]+\]@@g'
On Linux:
sed -r 's@\[[0-9]+\]@@g'
Upvotes: 4