dazz has asked for the wisdom of the Perl Monks concerning the following question:
I use the regex to get a matching substring with the 1st value within<span class="remaining-data">54MB used</span> <span class="expires-data-right-align">1.44GB remaining</span>
The output in $stgUsed is what I expect:(my $DataUsed) = $stgUsed =~ /"remaining-data">([+-]?(\d*\.)?\d+)(MB +|GB) used/; # trying to get just the digits. (my $unit) = $stgUsed =~ /(MB|GB)/; # match either MB or GB if ( $unit eq "GB"){ $DataUsed *= 1000; }
In want to capture just the number (315) and the units (MB) but $DataUsed in undef.DB<5> x $stgUsed 0 'class="remaining-data">315MB'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex problem
by haukex (Archbishop) on May 25, 2017 at 09:49 UTC | |
|
Re: Regex problem
by Corion (Patriarch) on May 25, 2017 at 09:42 UTC |