此匹配运算符用于匹配给定表达式中的任何关键字。起始m后面的括号可以是任何字符,将用于分隔正则表达式语句。
Regular expression variables include $, which contains whatever the last grouping match matched; $&, which contains the entire matched string; $`, which contains everything before the matched string; and $', which contains everything after the matched string.
以下是此函数的简单语法-
m//
如果失败,此函数返回0,如果成功,则返回1,
以下是显示其基本用法的示例代码-
链接:https://www.learnfk.comhttps://www.learnfk.com/perl/perl-m.html
来源:LearnFk无涯教程网
#!/usr/bin/perl -w $string="The food is in the salad bar"; $string =~ m/foo/; print "Before: $`\n"; print "Matched: $&\n"; print "After: $'\n";
执行上述代码后,将产生以下输出-
Before: The Matched: foo After: d is in the salad bar
这一章《Perl - m函数》你学到了什么?在下面做个笔记吧!做站不易,你的分享是对我们最大的支持,感谢!😊
如何在 Flutter 中实现这个 CircularProgressIndicator?