Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: remove 16 Zeros

by mr_ron (Chaplain)
on Oct 13, 2015 at 14:34 UTC ( [id://1144709]=note: print w/replies, xml ) Need Help??


in reply to remove 16 Zeros

Perl regular expressions can count as explained in perlretut - Perl regular expressions tutorial in the section on on matching repetitions. So /0{16}/ matches exactly 16 zeroes.

use strict; use warnings; my $line = "pvid 00c1be9a467335ce0000000000000000"; my $pvid; if ($line =~ /pvid\s+(.*)0{16}$/) { $pvid = $1 } print "$pvid\n"; __END__ 00c1be9a467335ce

Since the string you are trying to extract consists of hex digits, a slight improvement on the regex might be:  /pvid\s+([[:xdigit:]]*)0{16}$/ . Go to perldoc.perl.org and search for "character class" to learn more ...

Ron

Replies are listed 'Best First'.
Re^2: remove 16 Zeros
by Anonymous Monk on Oct 14, 2015 at 06:46 UTC

    Oh yeah. that works fine. I have to find out about 1000 PVID's from DISKS. So i list DISKS and read the Configuration of DISK's, where i must grep the string pvid and filter only he pvid.

    So this is the better solution.

    thank u Ron :-)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-03-28 22:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found