Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Regex help!

by shmem (Canon)
on Jun 09, 2013 at 08:33 UTC ( #1037917=note: print w/ replies, xml ) Need Help??

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'

Comment on Re: Regex help!
Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1037917]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2015-11-25 05:39 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (671 votes), past polls