title: Java regex to split words in a sentences with value and its metric as single word
body: <p>I am trying to split a sentence into a set of words. What I am looking is to consider also the metric when chunking numbers.</p>
  
  <pre><code>E.g (Made-up).
   document= The root cause of the problem is the temperature, it is currently 40 degrees which is 30 percent likely to turn into an infection doctor has prescribed 1-19666 tablet which contains 1.67 gpm and has advised to consume them every 3 hrs.
  </code></pre>
  
  <p>What is required, are set of words </p>
  
  <pre><code>the
  root
  cause
  problem
  ...
  40 degrees
  30 percent
  1.67 gpm
  1-19666 tablet
  3 hrs
  </code></pre>
  
  <p>What I have tried is </p>
  
  <pre><code>List&lt;String&gt; bagOfWords = new ArrayList&lt;&gt;();    
  String [] words = StringUtils.normalizeSpace(document.replaceAll("[^0-9a-zA-Z_.-]", " ")).split(" ");
  for(String word :words){
      bagOfWords.add(StringUtils.normalizeSpace(word.replaceAll("\\.(?!\\d)", " ")));         
      }                
  System.out.println("NEW 2 :: " + bagOfWords.toString());
  </code></pre>