开发者

help tweaking regular expression in perl

开发者 https://www.devze.com 2023-02-02 23:58 出处:网络
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

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

精彩评论

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