简体   繁体   English

如何递归匹配一定数量的数字?

[英]How to match a certain number of digits recursively?

I'm trying to match occurrences of 6-digit numbers from the HTML output from an array of matched tags: 我正在尝试从匹配标签数组的HTML输出中匹配出现的6位数字:

foreach (@name) {
        print $_->as_HTML =~ m/([0-9]*){6}/ . "\n";
};

What to do? 该怎么办? This doesn't work, as you may notice. 您可能会注意到,这不起作用。


Actually, I think I've got it: 其实,我想我已经明白了:

foreach (@name) {
        print $_->as_HTML =~ m/[0-9]{6}/g;
        print "\n";
};

You probably want the following: 您可能需要以下内容:

my @numbers = $_->as_HTML =~ m/\d{6,}/g;

Pull all numbers that are 6 digits or longer from the document. 从文档中拉出所有6位或以上的数字。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM