Using sed to eliminate characters around specific patterns, but not for others

I have a file with thousands of lines marked as follows:

{3203}

{1293}

{} XII

{x}

{VII}

etc...

I need to remove the brackets around the numbers , but not the letters (Roman numerals), so essentially it will look like

3203

1293

{} XII

{x}

{VII}

etc..

I would put what I tested so far, but I'm not particularly close to having any part of the sed statement be correct.

+4
source share
2 answers

This may be close to what you are looking for:

sed -e 's/{\([0-9]\+\)}/\1/g' inputfile 
+5
source

Failed to get it to work with sed, but it works if you have Perl:

 perl -pe 's/{(\d+)}/\1/' inputfile 
0
source

All Articles