in reply to Regex problem

You will be doing yourself a huge favor if you use a module to parse HTML instead of regexes. I discussed some of the options for parsing HTML and gave some example code here: "Two classic modules are HTML::Parser and HTML::TreeBuilder, but there are several others, such as Mojo::DOM. If the input is always XHTML, there's XML::Twig and many more XML-based modules."

use warnings; use strict; use Data::Dump; use Mojo::DOM; my $html = <<'END_HTML'; <span class="remaining-data">54MB used</span> <span class="expires-data-right-align">1.44GB remaining</span> END_HTML my $dom = Mojo::DOM->new($html); for my $e ($dom->find('span[class="remaining-data"]')->each) { dd $e->text; my ($val,$unit) = $e->text =~ /([+-]?(?:\d*\.)?\d+)(MB|GB) used/ or die "Couldn't parse '".$e->text."'"; dd $val, $unit; } __END__ "54MB used" (54, "MB")