title: Extract sub string from a string
body: <p>The content of my string (<code>MY_STRING</code>)could be in the following format:</p>
  
  <p><code>bla bla...this is the id of product bla bla:#31 5 2 0000 12please verify bla bla ...</code></p>
  
  <p>or</p>
  
  <pre><code>bla bla...this is the id of product bla bla: #31 5 2 0000 12, please verify bla bla...
  </code></pre>
  
  <p>or</p>
  
  <pre><code>bla bla...this is the id of product bla bla: #31 5 2 0000 12 please verify bla bla...
  </code></pre>
  
  <p>I want to <strong>extract out</strong> the product ID from the string. The product ID in above example is <strong>#31 5 2 0000 12</strong> </p>
  
  <p>The format of product ID is that <strong>it starts with # which is followed by random numbers (the length is unlimited), the spaces between numbers are arbitrary too</strong>. </p>
  
  <p>My current code to extract out product ID is:</p>
  
  <pre><code>Pattern pattern = Pattern.compile("^#\\d+(\\s+\\d+)*$");
  Matcher matcher = pattern.matcher(MY_STRING);
  if(phoneNrMatcher.find()){
      System.out.println(matcher.group(0));                   
  }
  </code></pre>
  
  <p>But it does not work, could some one help me where goes wrong? Probably the regular expression?</p>
  
  <p><strong>NOTE:</strong></p>
  
  <p>-In my example the content before &amp; after ID <strong>#31 5 2 0000 12</strong> is <strong>arbitrary</strong>.</p>
  
  <p>-product ID string always starts with # which is followed by a number immediately without space or other char</p>