title: How to find string in a character in R
body: <p>I know this is a very naive question, but I tried a lot but didn't find a way to count the number of occurrences of a specified substring within a character string in R.</p>
  
  <p>For example:</p>
  
  <pre><code>str &lt;- "Hello this is devavrata! here, say again hello"
  </code></pre>
  
  <p>Now I want to find the number of occurrences of <code>hello</code>, ignoring case. In this example, the answer should come out to be 2.<br>
  <strong>EDIT:</strong> I am wondering that it when I will find <code>ello th</code> then <code>str_count</code> will give occurrence <code>1</code> but I want the exact word surrounded by spaces occurrence means in this case it should give <code>zero</code>.<br> For example if I want to find <code>very good</code> in a particular <strong>string</strong> like:-<br></p>
  
  <p><code>It is very good to speak like thevery good</code><br></p>
  
  <p>And occurence should be <code>1</code> here not <code>2</code>. I hope you understand.</p>