Need some regex help in Java. I have a string, which contains text and always a date after it. Then after the date, without a space, a new text starts and ends with a date. and so on and on and on. I need to get all the text instances out with loop. It needs to exclude date from the beginning and expect date in the end. Could anyone suggest a good regex for it?
String candidateString = "dffsd fs sfd 12.12.12asd saddsa dasd 12.12.12fsadf sdfsdf sdf 10.10.10";
Pattern p2 = Pattern.compile(".*?(?![0-9][0-9].[0-9][0-9].[0-9][0-9])[a-zA-Z] (?=[0-9][0-9].[0-9][0-9].[0-9][0-9])");
Matcher matcher2 = p2.matcher(candidateString);
while (matcher2.find()) {
System.out.println(matcher2.group());
}
This code expects date in the end, but I can’t figure out how to exclude date from the beginning.
See if this is what you want?
This prints the below for me (Have included
|[pipes] to show the boundaries).and