title: Ruby regex gsub a line in a text file
body: <p>I need to match a line in an inputted text file string and wrap that captured line with a character for example.</p>
  
  <p>For example imagine a text file as such:</p>
  
  <pre><code>test
  foo
  test
  bar
  </code></pre>
  
  <p>I would like to use gsub to output:</p>
  
  <pre><code>XtestX
  XfooX
  XtestX
  XbarX
  </code></pre>
  
  <p>I'm having trouble matching a line though.  I've tried using regex starting with ^ and ending with $, but it doesn't seem to work. Any ideas?</p>
  
  <p>I have a text file that has the following in it:</p>
  
  <pre><code>test
  foo
  test
  bag
  </code></pre>
  
  <p>The text file is being read in as a command line argument.</p>
  
  <p>So I got</p>
  
  <pre><code>string = IO.read(ARGV[0])
  string = string.gsub(/^(test)$/,'X\1X')
  
  puts string
  </code></pre>
  
  <p>It outputs the exact same thing that is in the text file.</p>