Using the Match Operator (=~) in Ruby
📖 Scenario: You are working on a simple text analyzer that checks if certain words appear in sentences. This is useful for filtering messages or searching for keywords.
🎯 Goal: Build a Ruby program that uses the match operator =~ to find if a word exists inside a sentence.
📋 What You'll Learn
Create a variable called
sentence with a specific string.Create a variable called
word with a specific string.Use the match operator
=~ to check if word is in sentence.Print the result of the match operation.
💡 Why This Matters
🌍 Real World
Searching for keywords in text messages, logs, or user input is common in many apps.
💼 Career
Understanding how to find patterns in text is useful for roles in software development, data analysis, and quality assurance.
Progress0 / 4 steps