How does the regex match operator work? #946
-
Newbie here. I'm currently reading the documentation and came across the regex match operator (=~) on the simple expression language page. This is the first time I've seen such an operator and its functionality is not explained by the documentation. I also couldn't find a GitHub discussion related to this feature. Can someone explain it to me? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Currently learning BASH and stumbled upon this operator: https://tldp.org/LDP/abs/html/bashver3.html#REGEXMATCHREF Assuming eww's regex match operator work the same, then Is this correct? |
Beta Was this translation helpful? Give feedback.
-
Took the liberty to go through the source code. The regex match operator works exactly like described above. https://github.com/elkowar/eww/blob/master/crates/simplexpr/src/eval.rs#L240-L243 |
Beta Was this translation helpful? Give feedback.
Currently learning BASH and stumbled upon this operator: https://tldp.org/LDP/abs/html/bashver3.html#REGEXMATCHREF
Assuming eww's regex match operator work the same, then
a =~ b
is equivalent tomatches(a, b)
, wherea
is a string andb
is a regular expression.Is this correct?