I have a text box that the user types in name a file but if the user enters "/" or a "\" the app crashes. So what would be the best way that I can check for them and replace them or block them?
B4X:t=t.replace("/","")
not sure how java deals with special chars, might need to escape them like "\/" or "\\"
t.Replace(Chr(47), "\")
This code is identical to:Just for the record, as I bumped into the issue today. I needed to replace / by \ to make a path and found this thread.
Escaping did not work, replace never saw "/".
Finally, this worked :
B4X:t.Replace(Chr(47), "\")
I know the topic is old, but I post to avoid others to waste time on a non working solution.
t.Replace("/", "\")
Dim t As String = "a/b/c"
Log(t.Replace("/", "\"))