巴什正则表达式=〜运算符 [英] Bash regex =~ operator
问题描述
什么是运营商 =〜
叫什么名字?难道只是用来右侧靠在左侧比较?
为什么运行测试时,需要双括号?
IE浏览器。 [$短语=〜$关键字]
感谢您
-
什么是运营商
=〜
叫什么名字?
块引用>我不知道它有一个名字。该 bash的文档只是调用它的
=〜
运营商。 -
时只使用右侧靠在左侧比较?
块引用>右侧被认为是一个扩展的正前pression。如果左侧匹配,操作员返回
0
和1
其他。 -
为什么运行测试时,需要双括号?
块引用>由于
=〜
是[EX pression]
复合命令的操作员。
What is the operator =~
called? Is it only used to compare the right side against the left side?
Why are double square brackets required when running a test?
ie. [[ $phrase =~ $keyword ]]
Thank you
What is the operator
=~
called?I'm not sure it has a name. The bash documentation just calls it the
=~
operator.Is it only used to compare the right side against the left side?
The right side is considered an extended regular expression. If the left side matches, the operator returns
0
, and1
otherwise.Why are double square brackets required when running a test?
Because
=~
is an operator of the[[ expression ]]
compound command.
这篇关于巴什正则表达式=〜运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!