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/'
In reply to Re: Regex help!
by shmem
in thread Regex help!
by lpanokarren
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |