How do I get the content after the last comma in a string using a regular expression?
Example:
abcd,fg;ijkl, cas
The output should
You could try this:
public static void main(String[] args) { String s = " abcd,fg;ijkl, cas"; String[] words = s.split(","); System.out.println(words[words.length-1].trim()); }