title: Match gcc -L compiler arguments -- Expressions, with whitespaces only if they are surrounded with apostrophes
body: <p>Suppose that I have some gcc command line like this one below:</p>
  <pre><code>gcc main.c -o main -lwhatever -lsomeother -Lpath/to/whatever -L&quot;/path to the/someotherlib&quot;
  </code></pre>
  <p>How can I match <code>path/to/whatever</code> and <code>&quot;/path to the/someotherlib&quot;</code> (either with or without the apostrophes)?</p>
  <p>Probably I should use some lookarounds but I fail to figure out how exactly.</p>
  <p>I started to build an expression like the one below</p>
  <pre><code>(?&lt;=-L)(.*)(?=\s)
  </code></pre>
  <p>Then I added the apostrophes:</p>
  <pre><code>(?&lt;=-L)&quot;?(.*)&quot;?(?=\s)
  </code></pre>
  <p>Turns out I cannot solve the problem that way, because <code>.*</code> matches any character and somehow clashes with <code>\s</code> in the lookbehind (maybe it consumes it but I think I even have to be careful with this statement).</p>
  <p>If I put <code>[^\s]</code> in the place of <code>.</code>, then it would not count whether the expression is between apostrophes or not, the match would end at the first whitespace.</p>
  <p><a href="https://i.stack.imgur.com/ZmQEK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZmQEK.png" alt="" /></a></p>