title: Matching the ID with another String by splitting it or using regular expression
body: <p>Below are the sample examples of string. In the below four string example, you will find <code>userId</code> as a <code>key</code> always.</p>
  
  <pre><code>{siteRebateSenstvty=0;1,1;2, siteRedemptChg=16;30,77;40, userId=101}
  {sgmntId=1, userId=101}
  {predictedCatRev=0;101;1,1;201;2, predictedOvrallRev=77;2,0;1,16;3, sitePrftblty=77;2,0;1671679, topByrGms=12345.67, usrCurncy=1, vbsTopByrGmb=167167.67, userId=101}
  {zipCode=CA11 9QL, userId=101}
  </code></pre>
  
  <p>So now in my below method, I am trying to validate <code>str</code> value with <code>id</code>, I will be passing string and id to <code>isStringValid method</code>.</p>
  
  <pre><code>private boolean isStringValid(String str, String id) {
      boolean valid = false;
  
      System.out.println(str);
  
      return valid;
  }
  </code></pre>
  
  <p><strong>Problem Statement:-</strong></p>
  
  <p>Now I am trying to match <code>id value</code> with <code>userId value</code> in the above <code>JSON String</code>. Meaning if <code>id value is 101</code> then in the above <code>JSON String</code> <code>userId</code> value should also be 101. If any of them doesn't matches or userId value is not there in the string then set the <code>vaild boolean to false</code>.</p>
  
  <p>What is the best way to do this problem?</p>
  
  <p>I cannot do it like this-</p>
  
  <p><code>if(str.contains(id))</code> because it might be possible 101 is present as some number in any keys.</p>