This is my code
stopwordlist = \"a|an|all\" File.open(\'0_9.txt\').each do |line| line.downcase! line.gsub!( /\\b#{stopwordlist}\\b/,\'\') File.open(\'0_9_2.
The | operator in regex takes the widest scope possible. Your original regex matches either \ba or an or all\b.
|
\ba
an
all\b
Change the whole regex to:
/\b(?:#{stopwordlist})\b/
or change stopwordlist into a regex instead of a string.
stopwordlist
stopwordlist = /a|an|all/
Even better, you may want to use Regexp.union.
Regexp.union