0
How to get last 5 digits only by using *non-capturing group(?:) * in regex.
I am trying to get last 5 numbers as output in the number format 000-00000,by using non capturing group(? :) in regex. I had tried it by writing "(?:\\d{3}-)(\\d{5})". But i didn't reveice the required output. Pls reply me the correct regex. https://code.sololearn.com/cRraKewKwgYx/?ref=app
2 Respuestas
+ 4
Pattern p=Pattern.compile("(\\d{5})");
+ 2
Or
System.out.println( s.substring(s.lastIndexOf("-")+1) );