title: Regular Expression to find words separated with space, backtracking
body: <p>I have to find words separated by space. What best practice to do it with the smallest backtracking?</p>
  
  <p>I found this solution:</p>
  
  <pre><code>Regex: \d+\s([a-zA-Z]+\\s{0,1}){1,} in a sentence
  Input: 1234 this is words in a sentence
  </code></pre>
  
  <p>So, <code>this is words</code> - i have to check using regex <code>([a-zA-Z]+\\s{0,1}){1,}</code> and words <code>in a sentence</code> i have to check by constant words in regex <code>in a sentences</code>.</p>
  
  <p>But in this case regex101.com gives me debug with 4156 steps and this is Catastrophic Backtracking. Any way to avoid it?</p>
  
  <p>I have other more complicated example, where it takes 86000 steps and it does not validate.</p>
  
  <p>Main problem, that i have to find all words separated by space, but in the same time regex contains words separated by space (constants). This is where i have Catastrophic Backtracking.</p>
  
  <p>I have to do this using Java.</p>