巴什正则表达式=〜运算符 [英] Bash regex =~ operator

查看:142
本文介绍了巴什正则表达式=〜运算符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是运营商 =〜叫什么名字?难道只是用来右侧靠在左侧比较?

为什么运行测试时,需要双括号?

IE浏览器。 [$短语=〜$关键字]

感谢您


解决方案


  1.   

    什么是运营商 =〜叫什么名字?


    我不知道它有一个名字。该 bash的文档只是调用它的 =〜运营商。



  2.   

    时只使用右侧靠在左侧比较?


    右侧被认为是一个扩展的正前pression。如果左侧匹配,操作员返回 0 1 其他。



  3.   

    为什么运行测试时,需要双括号?


    由于 =〜 [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

解决方案

  1. What is the operator =~ called?

    I'm not sure it has a name. The bash documentation just calls it the =~ operator.

  2. 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, and 1 otherwise.

  3. Why are double square brackets required when running a test?

    Because =~ is an operator of the [[ expression ]] compound command.

这篇关于巴什正则表达式=〜运算符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆