java - Replacing Vowels In A String With Increasing Numbers -
java - Replacing Vowels In A String With Increasing Numbers -
i'm trying figure out way take string , replace vowels increasing number.
for example:
"abcdef" --> "0bcd1f" i tried replaceing vowels single symbol, seek replacing each occurrence of symbol increasing number. doesn't work though, because i'm setting word2 instance.
public static string getnumberstring( string s) { string word = s; string word1 = word.replaceall("[aeiouaeiou]", "@"); int c = 0; for( c = 0; c <= word.length(); c++) { string word2 = word1.replacefirst("@", integer.tostring(c)); } homecoming ""; } any help appreciated.
following should work. of returning empty string.
apart that, in java string immutable need update word2 have different string value in every iteration.
public static string getnumberstring( string s) { string word = s; string word1 = word.replaceall("[aeiouaeiou]", "@"); int c = 0; string word2 = word1; for( c = 0; c <= word.length(); c++) { word2 = word2.replacefirst("@", integer.tostring(c)); } homecoming word2; } java string replace
Comments
Post a Comment