title: Parsing single-quoted string with escaped quotes with Nom 5
body: <p>I'm new to Rust and Nom and I'm trying to parse a (single) quoted string which may contain escaped quotes, e.g. <code>'foo\'  bar'</code> or <code>'λx → x'</code>, <code>''</code> or <code>'  '</code>.</p>
  
  <p>I found the <code>escaped!</code> macro, whose <a href="https://docs.rs/nom/5.0.1/nom/macro.escaped.html" rel="nofollow noreferrer">documentation</a> says:</p>
  
  <blockquote>
    <p>The first argument matches the normal characters (it must not accept the control character), the second argument is the control character (like \ in most languages), the third argument matches the escaped characters</p>
  </blockquote>
  
  <p>Since I want to match anything but a backslash in the matcher for “normal characters”, I tried using <a href="https://docs.rs/nom/5.0.1/nom/macro.take_till.html" rel="nofollow noreferrer"><code>take_till!</code></a>:</p>
  
  <pre class="lang-rust prettyprint-override"><code>    named!(till_backslash&lt;&amp;str, &amp;str&gt;, take_till!(|ch| ch == '\\'));
      named!(esc&lt;&amp;str, &amp;str&gt;, escaped!(call!(till_backslash), '\\', one_of!("'n\\")));
  
      let (input, _) = nom::character::complete::char('\'')(input)?;
      let (input, value) = esc(input)?;
      let (input, _) = nom::character::complete::char('\'')(input)?;
  
      // … use `value`
  </code></pre>
  
  <p>However, when trying to parse <code>'x'</code>, this returns <code>Err(Incomplete(Size(1)))</code>. When searching for this, people generally recommend using <code>CompleteStr</code>, but that's not in Nom 5. What's the correct way to approach this problem?</p>