Timeline for answer to Does Ruby regular expression have a not match operator like "!~" in Perl? by Konrad Rudolph
Current License: CC BY-SA 4.0
Post Revisions
8 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Sep 14, 2023 at 20:15 | comment | added | Dogweather |
How about in a case statement's when clause?
|
|
| Aug 30, 2022 at 17:53 | comment | added | Allison |
The object you're calling the method on is a String (not a Regexp), though both can receive Object's !~ method by virtue of being objects. This method compares two objects via the left operand's class' =~ method. The example in your answer has a left operand of type string and a right operand/argument of type Regexp so it calls String's =~ method; if your left operand were a regexp, it would call Regexp's =~ method.
|
|
| S Aug 7, 2019 at 10:29 | history | suggested | Daniel | CC BY-SA 4.0 |
Fix link. And I had to move it to a reference in the bottom because StackOverflow's ridiculous rule that does not allow to change one single character.
|
| Aug 7, 2019 at 0:26 | review | Suggested edits | |||
| S Aug 7, 2019 at 10:29 | |||||
| May 28, 2018 at 20:52 | comment | added | panmari |
With ruby 2.4, there's also the somewhat nicer syntax RegExp#match?, which you can easily negate. According to the release notes, it does even fewer allocations than !~
|
|
| Jun 24, 2016 at 9:54 | comment | added | Tonči D. |
!~ is documented under Object.
|
|
| Dec 10, 2012 at 8:40 | vote | accept | user1793091 | ||
| Dec 7, 2012 at 8:04 | history | answered | Konrad Rudolph | CC BY-SA 3.0 |