+ 1
Doubt
System.out.println(“hello123”.replaceAll(“a-z”,””); Output is :hello123 Why? Iam not understanding I want 123 as my output instead it is getting hello123 even after replace method... why?
5 Respuestas
+ 1
\\D is regex for non-digit char
[a-z] is regex for char from a-z group of chars
+ 4
Hello There Haritha. You are a bit wrong there. Here's the corrected code :
System.out
.println("hello123".replaceAll("[a-z]", ""));
However, if you want to remove the Capital Letters too then you should write the following :
System.out
.println("hello123".replaceAll("[A-Za-z]", ""));
0
or
"hello123".replaceAll("\\D","")
0
zemiak i didnt understood ur concept
what is (“\\D”,””)mean
0
Arb Rahim Badsa grt explaination thank you