On Jan 12, 4:39   
> user_variable = 'some_word' # retrieved from 'gets.chomp'
> cleaned_variable = '^' + user_variable + '|\s' + user_variable + '(?!\w)'
>
> # print out variable to see if concat worked:
> puts cleaned_variable => prints out correct regex
>
> p some-sentence-string.gsub(%r{cleaned_variable},'TEST') # => prints
> out sentence unchanged

%r{foo} is the same as /foo/...you're using the name of the variable,
not the contents. You want:
/#{foo}/ or %r{#{foo}} or %r|#{foo}| or ...
or Regexp.new( foo )