Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Replacing characters  RSS feed

 
Lila Fowler
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

Im automatically creating a folder with user information, but i have to make sure that there are no illegal characters and if there are i should replace it with a "0" but although it goes into my if statement it refuses to replace the invalid character.

here is the relevant code



Any idea's?
thanks.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String.replace does not alter the string you're passing to it; rather, it returns the result of the replacement operation. You want something like " fileName = fileName.replace(... "
 
Lila Fowler
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
oh duh.. Thanks, works perfectly now.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!