title: Use regex on htmlParseTree in R
body: <p>I have an HTML internal doc that I want to strip character vectors from.  Specifically, I am trying to parse Google results.</p>
  
  <pre><code>##create search query
    vcSearchInput &lt;- "Alberta+Alabama+USA+latitude+longitude"
  
    ##scrape and parse google results to XML
    vcSearchOutput &lt;- getURL(paste0("http://www.google.com/search?q=",vcSearchInput))
  </code></pre>
  
  <p>from here, I can that exactly what I want comes after:</p>
  
  <pre><code>&lt;a href="http://maps.google.com/maps?um=1&amp;amp;ie=UTF-8&amp;amp;fb=1&amp;amp;gl=us&amp;amp;sa=X&amp;amp;ll=
  </code></pre>
  
  <p>I have figured out converting to character:</p>
  
  <pre><code>vaSearchOutput &lt;- paste(capture.output(vaSearchOutput,file="test.txt"),collapse="")
  </code></pre>
  
  <p>But, of course, my search string has TONS of special characters that require escaping.</p>
  
  <p>I tried:</p>
  
  <pre><code>gregexpr("http\\:\\/\\/maps\\.google\\.com\\/maps\\?um\\=1\\&amp;amp\\;ie\\=UTF\\-8\\&amp;amp\\;fb\\=1\\&amp;amp\\;gl\\=us\\&amp;amp\\;sa\\=X\\&amp;amp\\;ll\\=",vaSearchOutput,ignore.case=T)
  </code></pre>
  
  <p>I tried:</p>
  
  <pre><code>regmatches(regexpr("maps\\.google\\.com.*",vaSearchOutput,ignore.case=T),vaSearchOutput)
  </code></pre>
  
  <p>and received:</p>
  
  <pre><code>Error in so + attr(m, "match.length")[ind] : 
    non-numeric argument to binary operator
  </code></pre>
  
  <p>So how can I work with these kinds of variable types to find regular expressions?</p>