perl 正则表达式:无法理解 /^#/ 应该匹配什么
有一个我正在尝试调试的脚本,但我无法弄清楚这个正则表达式的含义,并且谷歌搜索“插入符”和“磅”没有帮助。
$line !~ /^#/
我确信这不是一个复杂的问题,但我在圣诞节之前都无法接触我所有的 Perl 书籍!
我当然知道 !~
的意思是“不匹配...”!
Got a script which Im trying to debug but I cant figure out the meaning of this regex and googling "caret" and "pound" isnt helping.
$line !~ /^#/
Not a complicated question I'm sure but I'm locked away from all my perl books until after xmas!
I know that the !~
means 'doesnt match...' of course!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
插入符是行的开头。 # 是一个#。它正在寻找非注释行(并假设注释从第一列开始,或者至少在任何
line
的开头)。Caret is beginning of line. # is a #. It's looking for non-comment lines (and assuming comments start in the first column, or at least at the beginning of whatever
line
is).这是检查所有不以“#”开头的行。通常是许多编程语言中的注释。
This is checking for all lines that do not start with "#". Typically comments in many programming language.