如何检查aaa或aab或Perl字符串?

TCM*_*TCM 0 perl

如果我想检查字符串是否包含aaa或aab或者?是否可以告诉我在绑定表达式中需要写什么模式?

$str = "Hello how are aaa you?";
print $str =~ m/what should i write here?/;
Run Code Online (Sandbox Code Playgroud)

zou*_*oul 8

$str =~ /a|aaa|aab/
Run Code Online (Sandbox Code Playgroud)

您可能希望检查常规运算符优先级,以确保不会被/^foo|bar$/(匹配^foobar$对比^(foo|bar)$)等事件所捕获.