title: Java match string until the first occurence of a different string
body: <p>I am facing other issues with Java's matcher. I am trying to match the content of my JSON using regex, without using external libraries. My JSON looks like this:</p>
  <pre><code>[
  {
  &quot;FIRST&quot;:&quot;Tom&quot;,
  &quot;LAST&quot;:&quot;Hanks&quot;,
  &quot;SUFFIX&quot;:&quot;&quot;
  },
  {
  &quot;FIRST&quot;:&quot;Sammy&quot;,
  &quot;LAST&quot;:&quot;Davis&quot;,
  &quot;SUFFIX&quot;:&quot;Jr.&quot;
  }
  ]
  </code></pre>
  <p>however, I only want to match the words in the first half, i.e. before the first <code>},</code> match. I tried to create a new pattern and matcher but I don't know how to progress, and how to break the while loop after the first occurence of <code>},</code></p>
  <pre><code>Pattern pattern = Pattern.compile(&quot;\&quot;([^\&quot;]*)\&quot;&quot;);
  Matcher matcher = pattern.matcher(loadJSONtoString(fileName).toString());
  Pattern pattern2 = Pattern.compile(&quot;},&quot;);
  Matcher matcher2 = pattern2.matcher(loadJSONtoString(fileName).toString());
  while(matcher.find())
     {
           myList.add(matcher.group());
           //if matcher2 encounters }. for the first time: break;  
     }
  </code></pre>