title: Remove part of String following regex match in Java
body: <p>I want to remove a part of a string following what matches my regex. </p>
  
  <p>I am trying to make a TV show organization program and I want to cut off anything in the name following the season and episode marker in the form SXXEXX where X is a digit. </p>
  
  <p>I grasped the regex model fairly easily to create "[Ss]\d\d[Ee]\d\d" which should match properly. </p>
  
  <p>I want to use the Matcher method end() to get the last index in the string of the match but it does not seem to be working as I think it should. </p>
  
  <pre><code>Pattern p = Pattern.compile("[Ss]\\d\\d[Ee]\\d\\d");
  Matcher m = p.matcher(name);
  
  if(m.matches())
      return name.substring(0, m.end());
  </code></pre>
  
  <p>If someone could tell me why this doesn't work and suggest a proper way to do it, that would be great. Thanks.</p>