how to check if string contains '+' character
java, match, string
Solution
You need this instead:
if(s.contains("+"))
`contains()` method of `String` class does not take regular expression as a parameter, it takes normal text.
EDIT:
String s = "ddjdjdj+kfkfkf";
if(s.contains("+"))
{
String parts[] = s.split("\\+");
System.out.print(parts[0]);
}
OUTPUT:
ddjdjdj
Problem
I want to check if my string contains a + character.I tried following code ``` s= "ddjdjdj+kfkfkf"; if(s.contains ("\\+"){ String parts[] = s.split("\\+); s= parts[0]; // i want to strip part after + } ``` but it doesnot give expected result.Any idea?