Saari Development

Ali Rizvi's Technical Blog as a Professional Software Development Engineer

Ruby: Searching for a variable string using grep

leave a comment »

I was looking for a way to search for a variable string inside a ruby method and I think I have found _a_ solution.

def print_line_containing(file, str){str}/).each do |line| puts "#{line}" end

def print_line_containing(file, str1, str2){str1}\s+#{str2}/).each do |line| puts "#{line}" end

Written by imsaar

April 29, 2006 at 1:52 am

Posted in general

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: