Hiya All,
Back again with more noobie questions ;}
I’ve been playing with some basics of opening and writing to files. But
have come up stuck trying to search inside a given file.
I have small method for matching a search string entered by a user,
against one of three in a .txt file. The method is available here:
I know I’m missing something fundamental but I can’t pin it down. An
error is produced that says “Type mismatch: string given” for the =~
However, I used this in a simpler version as below and it works:
first_string = “banana”
second_string = “I like a banana with my breakfast”
puts “\nWe have banana!!” if second_string =~
/#{Regexp.quote(first_string)}/
I’ve tried all sorts and can’t get the method linked above to work.
If anyone has a few moments could you look over this for me?
Out of interest, other examples I’ve worked on are at:
https://github.com/MarkCTest/Script-Bucket/blob/master/externalFile.rb
Thanks as always,
DE