title: Matching two strings and extracting the matched character in R
body: <p>Consider I have the below mentioned input character;</p>
  
  <pre><code>text_input &lt;- c("ADOPT", "A", "FAIL", "FAST")
  test &lt;- c("TEST", "INPUT", "FAIL", "FAST")
  </code></pre>
  
  <p>I would like to match both the inputs and extract the words which occurred in common in text_input, I would like to something similar to <code>str_extract</code>.</p>
  
  <p>I do understand that <code>str_extract</code> uses a matching pattern or word to do it, but,my test data consists of around 500,000 words. Any inputs would be really helpful.</p>
  
  <p>Expected Outcome:</p>
  
  <pre><code>"FAIL", "FAST"
  </code></pre>
  
  <p><strong>EDIT</strong></p>
  
  <p>Just adding one more question here... What happens when the Input is a pure string, like, the one provided below;</p>
  
  <pre><code>text_input &lt;- c("‘Data Scientist’ has been named the sexiest job of the 21st century by Harvard Business Review. The same article tells us that “demand has raced ahead of supply” and that the lack of data scientists “is becoming a serious constraint in some sectors.” A 2011 study by McKinsey Global Institute found that “there will be a shortage of talent necessary for organizations to take advantage of big data” – a shortage to the tune of 140,000 to 190,000 in the United States alone by 2018.")
  
  test &lt;- c("Data Scientist", "McKinsey", "ORGANIZATIONS", "FAST")
  </code></pre>
  
  <p>Is it possible to perform string match even in this case, as mentioned above. </p>
  
  <p>Note: Changed the input and testing string.</p>