title: Apply regular expressions to compare values in data frames of different length in R
body: <p>I am trying to apply a regular expression to match values in two data frames of different length in R. My objective is to retain only the values that match the regex in both data frames.</p>
  
  <p>An example of the dataset would be:</p>
  
  <pre><code>a&lt;-c('item1','item2','item4')
  b&lt;-c('item1','\t item2','item3','item4')
  </code></pre>
  
  <p>I tried to do <code>grepl(a$. , b$.)</code> but it only works for the 'first' row. Just to explain, the values in the two columns have a common kernel name but there might be small differences, so I do need some kind of regex.</p>
  
  <p>If the code worked, I would get that the new object 'c', which could also be a filtered version of a, would be equal to</p>
  
  <pre><code>c&lt;-c('item1','item2','item4')
  </code></pre>
  
  <p>Peace to you</p>