title: Dismissing trailing white space at the end of a String when using a regex?
body: <p>The problem I’m facing here is that the current regex I created does not fully work. If there is no white space at the end of my String it fails. My question is there any way to resolve this? </p>
  
  <p>Here are the details of the question:</p>
  
  <p>I need a regex that ensures Strings conform to the following format,</p>
  
  <pre><code>“LL=xxxxxx LL=xxxxxxxxx LL=xxxxxxx”
  </code></pre>
  
  <p>L = Letter.
  X = Letter or number or punctuation mark.</p>
  
  <p>The closest regex I have is,</p>
  
  <pre><code>([\\pL]{2}=[\\pL|\\pN|\\pP]+ )+
  </code></pre>
  
  <p>But this regex does not work and will only work if the String is in the Format:</p>
  
  <pre><code>“LL=xxxxxx LL=xxxxxxxxx LL=xxxxxxx ”
  </code></pre>
  
  <p>Here is code I use to check:</p>
  
  <pre><code>    final String regex1 = "([\\pL]{2}=[\\pL|\\pN|\\pP]+ )+"; 
      String x = "xx=xxxxxx xx=xxxxxxxxxm xx=xxxxxxx xx=xxxxxxx"; // This is what I need!
      String y = "xx=xxxxxx xx=xxxxxxxxxm xx=xxxxxxx xx=xxxxxxx "; // This works, no good
      System.out.println(x.matches(regex1));
      System.out.println(y.matches(regex1));
  </code></pre>