title: grep at the beginning of the string with fixed =T in R?
body: <p>How to grep with <code>fixed=T</code>, but only at the beginning of the string?</p>
  
  <pre><code>grep("a.", c("a.b", "cac", "sss", "ca.f"), fixed = T)
  # 1 4
  </code></pre>
  
  <p>I would like to get only the first occurrence. 
  [Edit: the string to match is not known in advance, and can be anything. "a." is just for the sake of example]</p>
  
  <p>Thanks.</p>
  
  <p>[Edit: I sort of solved it now, but any other ideas are highly welcome. I will accept as an answer any alternative solution.</p>
  
  <pre><code>s &lt;- "a."
  res &lt;- grep(s, c("a.b", "cac", "sss", "ca.f"), fixed = T, value = T)
  res[substring(res, 1, nchar(s)) == s]
  </code></pre>
  
  <p>]</p>