I have the below string
String srcString = "String1.String2.String3";
I want to split “srcString” on “.”
Using srcString.split(“.”) is matching all the characters.
What is the regex to match a “.” ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In regex dot is special character representing any character except line separator (to also make it match line separators use
Pattern.DOTALLflag).Anyway, use
split("\\.")Explanation:
.we can add\before it so we end up with regex\.\is also special in string literal" "we also need to escape it there, so to express\.we need to write it as"\\.".