I am very confused about how Java regular expressions work. I want to extract two lines from a template that looks like this:
String userstatus = "username = not ready";
Matcher matcher = Pattern.compile("(\\.*)=(\\.*)").matcher(userstatus);
System.out.println(matcher.matches());
But when printed, this will return false. I want to get the username, as well as the space that follows it, and the status bar to the right of the equal sign, and then save them both separately and in two lines.
How can I do it? Thanks!
So, the resulting lines should look like this:
String username = "username ";
String status = " not ready";
source
share