title: Regular Expression: Match whole numbers in string
body: <p>I'm trying to match numbers using JavaScript in a string with the following format:</p>
  
  <pre><code>NUM;#username;#NUM;#username
  </code></pre>
  
  <p>so for example, in the following string: </p>
  
  <pre><code>252;#Lemmywinks07;#27;#Trogdor
  </code></pre>
  
  <p>I would capture <strong>252</strong> and <strong>27</strong>.</p>
  
  <p>However, I'm having issues building a regular expression that captures both numbers.  I thought that using a global would match both, but when I run the following:</p>
  
  <pre><code>/\d+/g.exec("252;#Lemmywinks07;#27;#Trogdor");
  </code></pre>
  
  <p>It returns: [252] and not [252, 27]</p>
  
  <p>I should note that I do not want to match numbers in a username (which usernames cannot only be numbers).  So it looks like I would match whole numbers that are either between ";#" or a whole number that precedes ";#".  </p>
  
  <p>Thanks in advance!</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Examples now include numbers in usernames.  I do not want to match numbers in usernames.  </p>