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

30th Dec 2021, 2:07 PM
Jawahirullah
Jawahirullah - avatar
2 Respostas
+ 4
Pattern p=Pattern.compile("(\\d{5})");
30th Dec 2021, 2:36 PM
JaScript
JaScript - avatar
+ 2
Or System.out.println( s.substring(s.lastIndexOf("-")+1) );
30th Dec 2021, 3:05 PM
SoloProg
SoloProg - avatar