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 ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: remove 16 Zeros
by Anonymous Monk on Oct 14, 2015 at 06:46 UTC |