title: Specific regex not working in R
body: <p>I'm trying to find whether a string pattern; <code>(&lt;double num&gt;&lt;space&gt;&lt;an operator&gt;&lt;space&gt;&lt;double num&gt;)</code> e.g. (14.0 + 46.0) exists in a given string using a regex in R. There can be 4 operators +,-,* and /.</p>
  
  <p>There are two main patterns. Regex for the 1st pattern identifies that the pattern exists in the string "s" </p>
  
  <pre><code>#Pattern 1
  s = "(14.0 + 46.0)"
  
  #Regex
  grep("^\\(-?\\d*\\.\\d{1}\\s[\\+\\-\\*\\/]\\s-?\\d*\\.\\d{1}\\)$", s)
  </code></pre>
  
  <p>I'm trying to find the same pattern in a different string s1 and s2. I modified the first regex by adding <code>.*</code>  (any character) to the beginning and end of the string <code>("^.*   .*$")</code>. I have checked the regex in <a href="https://www.freeformatter.com/regex-tester.html" rel="nofollow noreferrer">this online checker</a> and it works. But it doesn't work in R studio.</p>
  
  <pre><code>#Pattern 2
  s1 = "((5.0 - 50.0) - 15.0)"
  s2 = "(15.0 - (5.0 - 50.0))"
  
  #Regex
  grep("^.*\\(-?\\d*\\.\\d{1}\\s[\\+\\-\\*\\/]\\s-?\\d*\\.\\d{1}\\).*$", s1)
  </code></pre>