Hey guys, so i've posted here before about regex, and i was told that some of you may be able to check my regexes for errors after i have created them. I have one that looks like it should work to me, but it absolutely will not.
public static String hitInput = "[CHAT WINDOW TEXT] [Sun Nov 29 11:34:13] Guardian of Water attacks Kyton's Rebuke [BH] : *hit* : (20 + 108 = 128 : Threat Roll: 3 + 108 = 111)";
public static String hitRegex = "^.*\\]\\s+(.+)\\s+attacks\\s+(.+)\\s+:\\s\\*(?:[a-z][a-z]+)\\*\\s+:\\s.*\\+\\s(\\d+)\\s.+\\s+:\\s$";
public static Pattern hitPattern = Pattern.compile(hitRegex);
public static Matcher hitMatcher = hitPattern.matcher(hitInput);
//the tester
public static void hitMatch() {
boolean matchesHit = hitMatcher.matches();
if (matchesHit == true) {
String one = hitMatcher.group(1);
String two = hitMatcher.group(2);
String three = hitMatcher.group(3);
String four = hitMatcher.group(4);
System.out.println(one);
}
else System.out.println("DOESNT MATCH");
}
anyone know why this doesnt match?
TJ