title: Good way to check if a String ends with a Regex String
body: <p>I need to check if a given String ends with a Regular Expression String. I have written the following code:</p>
  
  <pre><code>public static void main(String[] args) {
      String str = "wf-008-dam-mv1";
      String regex = "mv(\\d)?$";
      Pattern pattern = Pattern.compile(regex);
      Matcher matcher = pattern.matcher(str);
  
      if(matcher.find() &amp;&amp; matcher.end() == str.length()) {
          System.out.println("Ends with true");
      } else {
          System.out.println("Ends with false");
      }
  }
  </code></pre>
  
  <p>Here the <code>str</code> can ends with or without number. Is it a good way to do it?</p>