What does the method do! ~ With a string in Ruby

From @sawa's answer: stack overflow

What does it do !~?

Example:

re = /[^\d.,]/
"0.0687987167581341,0.120311605902415,89.8399554017928,198.151088713489" !~ re

I could not find the documentation in String or Regexp

+3
source share
2 answers

The method !~is the inverse of =~, that is !(=~). From the Ruby Object#!~documentation :

[obj! ~ other] returns true if the two objects do not match (using the = ~ method), false otherwise.

, String#=~ / , , , nil String#!~ return false, , true .

+5

, . =~

: Ruby -, "! ~" Perl?

-, - .

+1

All Articles