java - How to check weather string contains single backslash? -
i want check if string contains "\" or not. used string method contains(), not working
string path = "d:\steve\"; if(path.contains("\"){ path = path.replaceall("\\\\",""); }
use escape character \
public class test{ public static void main(string[] args) { string str = "a\\b"; system.out.println(str.contains("\\")); } }
a character preceded backslash (
\
) escape sequence , has special meaning compiler.
https://docs.oracle.com/javase/tutorial/java/data/characters.html
Comments
Post a Comment