What does =~ mean in Ruby

I can't find an answer on Google about what =~ means in Ruby.

Here is an example I am trying to understand

 if regex =~ file

Open in new window

and file in this case is from a loop:

Dir.entries(real_dir).each do |file|

Open in new window

Who is Participating?
Paul JacksonConnect With a Mentor Software EngineerCommented:
=~ is used to compare a string with a regular expression, will return true if a match is found or nil if there is no match.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.