http://www.perlmonks.org?node_id=1037917


in reply to Regex help!

Basically, I need to extract disk capacity from the data center description which basically has a numeric value preceding the unit of measure like GB
...
echo $x | sed "s/^[^0-9]*\([0-9]*[.]*[0-9]*\)[^0-9A-Z]*GB.*/\1/g"

Why so complicated? This should do:

echo $x | sed "s/.\+ \([0-9]\+\)GB.*/\1/g"

But as LanX says, sed(1) doesn't use PCRE. Read perlrun and perlre to understand the following:

echo $x | perl -ple 's/.+?(\d+)\s?GB.*/$1/'
perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'