title: Using Rlike in Hive to find Regex patterns
body: <p>I want to filter a column to check for words like head, att, space etc and I am using the following query</p>
  
  <pre><code>select * from tablename where (column_name like '%head%' or column_name like '%att%' or column_name like '%space%')
  </code></pre>
  
  <p>But the problem with the query is, it filters out even words like headgear, attitude, spaceship. I want to filter only rows that have particular word like head, att, space. I tried putting a space to each word,</p>
  
  <pre><code>select * from tablename where (column_name like '%head %' or column_name like '%att %' or column_name like '%space %')
  </code></pre>
  
  <p>But this doesn't filter the word, if head is present towards the end of the sentence. </p>
  
  <p>Just figured out that we can use something like <code>rlike</code> in Hive to solve this issue. But I tried doing it without much success.</p>
  
  <p>Can anybody help me in using <code>rlike</code> to filter only rows that contain only words like head, att, space.</p>
  
  <p>Thanks</p>
  
  <p>Adding update..</p>
  
  <p>Suppose the input is as follow</p>
  
  <pre><code>Tom's head
  my head is big
  I am having headache
  att is bad
  attitude is bad
  bad is att
  There is more space
  spaceship
  space is looking cool
  </code></pre>
  
  <p>The output should be,</p>
  
  <pre><code>Tom's head
  my head is big
  att is bad
  bad is att
  There is more space
  space is looking cool
  </code></pre>
  
  <p>The following rows should be removed because I am only interested on words like head, att and space, whenever it occurs in the sentence. I am not interested in filtering headache, attitude and spaceship.</p>
  
  <pre><code>I am having headache
  attitude is bad
  spaceship
  </code></pre>
  
  <p>Thanks</p>