Skip to main content
10 events
when toggle format what by license comment
Mar 9, 2023 at 0:54 history edited Clint Pachl CC BY-SA 4.0
Show and alternative solution (thanks @ShadowRanger), and fix documentation URL.
Mar 9, 2023 at 0:34 history edited Clint Pachl CC BY-SA 4.0
fix error about return value
Feb 23, 2023 at 15:42 comment added ShadowRanger @scrthq: Or for minimal characters for code golfing, use === instead, /bcd/i==='aBcDe'. .match? is definitely more descriptive for normal code though.
Mar 7, 2020 at 17:53 comment added scrthq alternatively, use match? to return a boolean: /bcd/i.match?('aBcDe')
Feb 14, 2020 at 3:59 history edited the Tin Man CC BY-SA 4.0
added 21 characters in body
Mar 16, 2018 at 13:23 comment added slindsey3000 !!('aBcDe' =~ /bcd/i) will evaluate to true or false. Use the !! idiom
Mar 16, 2018 at 13:21 comment added slindsey3000 This does NOT evaluate as true. It evaluates to 1 which is not true.
Mar 28, 2016 at 20:33 comment added the Tin Man Using a regular expression this way isn't necessarily going to be faster than using 'aBcDe'.downcase.include?('bcd'). Regex have their purpose but don't use them when the built-in methods are faster. Benchmarking with the actual data being tested can reveal much.
Apr 24, 2015 at 22:01 comment added Jacklynn If you are matching against user input and using this technique, remember to use Regexp.escape on the string. For most use cases, some_str.include? substr.downcase() should work faster and be more readable.
Jul 1, 2014 at 10:20 history answered Clint Pachl CC BY-SA 3.0