I have this code that I need to parse the process ID from text:
@Test
public void testParseProcessId() {
String text = "Private property of Exodus: 1016@localhost";
Pattern pattern = Pattern.compile("^Private property of Exodus:\\s(\\d+)");
String matched = null;
Matcher matcher = pattern.matcher(text);
if (matcher.matches()) {
matched = matcher.group(1);
}
assertEquals("1016", matched);
}
The test fails, but I have checked the the regex should be correct, what am I missing here?