title: regex to match this repeating pattern?
body: <p>I was able to match the string <code>[ORG] someText</code> with this regex: <code>/^\[(ORG|PER|LOC)]\s[^\W_]+$/</code></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var selectedText = "[ORG] dd";
  
  if (selectedText.match(/^\[(ORG|PER|LOC)]\s[^\W_]+$/)) {
      console.log("working");
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>The input text could have anything in the tag followed by any word.</p>
  
  <hr>
  
  <p>Now I have the text as: <code>[ORG] Lorem [ORG] ipsum</code> (ending with a space)</p>
  
  <p>I tried to match this by grouping the pattern and repeating it with a <code>+</code> (one or more occurances).</p>
  
  <p>This way: <code>/^(\[(ORG|PER|LOC)]\s[^\W_]\s)+$/</code></p>
  
  <p>However it doesnt match.</p>
  
  <p><strong>Basically, it should match:</strong></p>
  
  <pre><code>[tag] sometext
  
  [tag] sometext [tag2] someOtherText // ending with or without a space
  </code></pre>
  
  <p>So, in general, it needs to match a pattern of <code>a tag followed by a space and a word</code>.</p>
  
  <p><strong>What it shouldnt match:</strong></p>
  
  <pre><code>[tag] sometext someMoreText
  
  [tag] sometext someMoreText [tag9]
  
  [tag] [tag9] sometext someMoreText 
  </code></pre>