如何在Perl中组合两种模式

我想将这两个正则表达式合二为一
next if $line =~ /^#/ or $line =~ /^d+-d+/;

回答

“或”很简单:使用交替|

next if $line =~ /^#|^d+-d+/

你甚至可以考虑^

/^(?:#|d+-d+)/


以上是如何在Perl中组合两种模式的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>