What is the proper syntax for a method that checks a string for a pattern, and returns true or false if the regex matches?
Basic idea:
def has_regex?(string)
pattern = /something/i
return string =~ pattern
end
Use case:
if has_regex?("something")
# woohoo
else
# nothing found: panic!
end
has_regex?
, just doif "something" =~ /something/i
– Compline