title: get line from file and use as regular expression(regex)
body: <p>I made a file(.txt) to put regular expression.<br>
  Each line contain one regex, I want to read regex from file and then make a regex like <code>boost::regex exp(line);</code> that <code>line</code> stand for regex that I got it from file.<br>
  I use function <code>regex_search(text, what, exp)</code> to match exp in text. but it doesn't match, When I straight use <code>boost::regex exp("((?&lt;destination_ip&gt;\\S+)?)");</code> it match clearly.<br>
  so how can I get line from file and use as <code>boost::regex exp(line);</code>?</p>
  
  <hr>
  
  <p>my code that stream to file is:  </p>
  
  <pre><code>using namespace boost;
  ifstream rgxFile("regex.txt", ios::in);
  smatch what;
  
  while(getline(rgxFile, line))
  {    
      regex exp(line);
      if( regex_search(text, what, exp) )
      {
          cout&lt;&lt;"destination IP: "&lt;&lt;what["destination_ip"]&lt;&lt;" ";   
      }
      else
      {
          cout&lt;&lt;"Nothing Found.";
      }
  }   
  </code></pre>
  
  <p>I think something's wrong with reading file and get line!</p>
  
  <p>Update:</p>
  
  <p>There is a log file that show accessed to web site. i.e. this is one line of log file:</p>
  
  <pre><code>  192.168.1.9
  </code></pre>
  
  <p>(it contain another things, But that's enough).</p>
  
  <p>I want to get IPs and use them. That regex is good, But some of line contain something that didn't match.</p>
  
  <p>So I need a text file contain many regexes. If one of text line didn't match, use another regex to match it.</p>
  
  <p>All regex matches all of text file(log.txt). but when I put regex into the file and read them, it doesn't match any thing.<br/>
  <br/>
  This is exactly regex in regex.txt :<br/></p>
  
  <pre><code>((?&lt;destination_ip&gt;\\S+)?)(\\s[+-]){2} \\[(?&lt;timestamp&gt;\\d{2}\/\\w{3}\/\\d{4}:\\d{2}:\\d{2}:\\d{2})\\s+[+-]\\d{4}\\] \"(?&lt;referer_uri&gt;.*)\"&lt;br/&gt;
  </code></pre>
  
  <p>This is one line of access file(log.txt):<br/></p>
  
  <pre><code>192.168.1.9 - - [20/Apr/2014:07:46:19 -0400] "GET /dvwa/favicon.ico HTTP/1.1" 200 1406 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:28.0) Gecko/20100101 Firefox/28.0"
  </code></pre>