Skip to content

Welcome to Tech by Example

Menu
  • Home
  • Posts
  • System Design Questions
Menu

Ruby regex match in an if check

Posted on October 5, 2022October 5, 2022 by admin

Overview

We can use the below sign to have ruby regex match in an if check

=~

Program

Let’s see an example of the same

if /\d/ =~ "3" 
    puts "Match"
else 
    puts "No match"
end

Output

Match

Note: Check out our system design tutorial series System Design Questions

©2025 Welcome to Tech by Example | Design: Newspaperly WordPress Theme