开发者

help tweaking regular expression in perl

Can some开发者_JAVA技巧one help me tweak this regex? It's grabbing 72.49 GB and I'm ONLY interested in the value 72.49

$line =~ m/(backup-size)[:=](.+)/

Raw String:

Tue Jan 04 05:45:34 2011: db2.mil.mad:backup:INFO: backup-size=72.49 GB


Try this:

$line =~ m/backup-size[:=]([\d.]+) GB/;

To select both the size and the unit in separate groups:

$line =~ m/backup-size[:=]([\d.]+) (.B)/;


$line =~ m/backup-size[:=](\d+\.?\d*)\s*[KMG]B/i;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜