Re: [問題] 請問如何以regular expression搜尋字串 …
※ 引述《megaman1206 (megaman)》之銘言:
: 因為index只能搜尋固定字串
: 如果我要搜尋一個可以由正規表達式表示的多種字串
: 除了每種字串搜尋一次
: 請問還有更快的方法嗎?
: 感謝
自問自答
my $ip = "64.156.215.240";
while ($ip =~/(\d+)/g) {
printf "found '$1' ending at location %d\n", pos($ip);
}
從 Mastering Regular Expressions找到的答案= =
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.138.155.189
Perl 近期熱門文章
PTT數位生活區 即時熱門文章