What empty regular expressions match in ruby?

after the RoR security tutorial (here) , I wrote something in the lines

@@private_re = //
def secure?
  action_name =~ @@private_re
end

The idea is that in the base case this should not match anything and return nil. the problem is that it is not. I worked currently using a meaningless line, but I would like to know the answer.

+3
source share
2 answers

An empty regular expression matches each line successfully.

Examples of regular expressions that do not always match:

  • /(?=a)b/
  • /\Zx\A/
  • /[^\s\S]/
+5
source

, - , // .

, @@private , , . , , @@private = /.../ , .

+1

Source: https://habr.com/ru/post/1761627/