Find a substring in a string

At first, check below points.

* Fix variable name "text" to "line".
* HELLO is not a "grobal variable", this name is a "constant".

Next, try this code.

    if /^#{HELLO}\s+.*$/ =~ line
       puts "#{HELLO} found"
    end

"(?:)" has other meanings in regex literals.
Use "#{expr}" for substitutions in string and regex literals.

Last, This documents for you.
http://ruby-doc.org/docs/ProgrammingRuby/html/language.html

···

--
Posted via http://www.ruby-forum.com/.