Reputation: 3898
I have A small string which include digit for example
"1 Al-Fâtihah"
,"2 Al-Baqarah"
,"3 Âl-'Imrân"
,"4 An-Nisâ'"
,"5 Al-Mâ'idah"
,"6 Al-An'âm"
,"7 Al-A'râf"
,"8 Al-Anfâl"
I want to remove digits from the string.working on android java
Upvotes: 1
Views: 2212
Reputation: 345
String s = "abcd123bcd";
s = s.replaceAll("\\d", "");
This will do the trick
Upvotes: 1
Reputation: 11131
use String.replaceAll(String,String)
method...
ex:
String s = "awhefqo1234akwfn";
String string = s.replaceAll("[0-9]", "");// prints awhefqoakwfn
here [0-9]
indicates a regular expression which replaces all digits with a empty String
Upvotes: 3
Reputation: 6112
Use replaceAll()
method of String
class.
string.replaceAll("\\d*$", "")
Upvotes: 1
Reputation: 4733
If the digits are only at the beginning of the String
you could do it like this:
String res = string.substring(2, string.length);
Upvotes: 3