Originally Posted by
wkqktlfj
I tried
int[] number = {1,2,3,4,5,6,7,8,9};
if(original.length() == number)
{
}
but i dont know how to replace them.
First, you need an array to map number to string, like this:
String[] number = {"zero","one","two","three","four","five","six","seven","eight","nine"};
And then you need to split your string to list of word. (token your string)
String[] words = your_data.split(" ");
After that you need to go through your words & check if there has any number from 0->9
for(String word : words){
//check word & replace here
}
Ok, by now you need to check if it's number & replace it.
if(word.lengh() == 1){
char c = word.charAt(0);
if(c >= '0' && c <='9')
return number[c - '0'];
}
Incase you know ascii code, you code compare like that:
int charCode = word.charAt(0);
if( charCode >= 48 && charCode <= 57){
return number[charCode - 48];
}
I think all would be clearly now, you need to think about it again & again and do coding by your self.
If you need any help, just post your code then I & others would happy to help you.
Happy Coding