Sam Sam - 1 month ago 6
Java Question

How to check if String has a Letter after a specific letter?

Example:

String letter = "abc+ab.c+abc.ab";


How to check if String letter contains
.
after last
+
?

Answer

About your modified question: to match . any time after + char try this:

Letter.matches(".*\\+.*\\..*");

Note: you it was necessary to escape + and . with \\ to match dot and plus literally, since those have a special meaning in regex.

Update: If you only want to match only if there is a dot after last + you could do this:

Letter.matches(".*\\+.*\\.[^+]*");

where the [^+] part means any char except +.

BTW: I would name your String letter instead of Letter because of naming conventions