+ 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 RĂ©ponses
+ 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