title: regex to extract a word
body: <p>I'm trying to extract a single word from a line of text. As I understand it, Powershell regexes are <em>almost</em> the same as PCREs (and I have a way of easily testing PCREs). I have a file containing (amongst other things) something like...</p>
  
  <pre><code>ignore=thisline
  username=symcbean
  dontRead=thisEither
  </code></pre>
  
  <p>And I want to get the value associated with "username".</p>
  
  <p>I know that the LHS of '=' will contain "username", optionally surrounded by whitespace, and the RHS will contain the value I am trying to extract (optionally surrounded by whitespace). The string I am looking for will match \w+, hence:</p>
  
  <pre><code>(?&lt;=username=)\w+ 
  </code></pre>
  
  <p>works for the case without additional whitespace. But I can't seem to accommodate the optional white space. For brevity I've only shown the case of trying to handle a whitespace before the '=' below:</p>
  
  <pre><code>(?&lt;=username\s*=)\w+   - doesn't match with or without additional space
  (?&lt;=username\W+)\w+    - doesn't match with or without additional space
  (?&lt;=username[\s=]*)\w+ - doesn't match with or without additional space
  </code></pre>
  
  <p>However in each case above, the group in the look-behind zero-width assertion (/username\s*=/, /username\W+/, /username[\s=]*/) matches the relevant part of the string.</p>
  
  <p>I'm hoping to get a single value match (rather than array).</p>