fork download
  1. import java.util.regex.Matcher;
  2. import java.util.regex.Pattern;
  3.  
  4.  
  5. public class Main{
  6.  
  7. public static void main(String[] args) {
  8. String xPathData = "/hrdg:data/hrdg:meeting[@code='30J7Q']/hrdg:event[@id='2545525']/hrdg:selection[@id='31192111']";
  9. Pattern selectionIdPattern = Pattern.compile(".*/hrdg:selection\\[@id=\'(\\d+)\'\\]");
  10. Matcher matcher = selectionIdPattern.matcher(xPathData);
  11. if (matcher.find()) {
  12. String selectionId = matcher.group(1); // now matches 31192111
  13. System.out.println(selectionId);
  14. }
  15. }
  16. }
Success #stdin #stdout 0.08s 380224KB
stdin
Standard input is empty
stdout
31192111