Regex to match both slash in JAVA

Viewed 49150

I want to match forward slash / or back slash \ in particular string for e.g.:
1. Hi/Hello/Bye/
2. Hi\Hello\Bye\
3. Hi\Hello/Bye\
4. HiHelloBye
In the given strings only the last record should not be matched because it does not contain either / or \.

What I am using

if (strFile.matches(".*//.*"))
{
    //String Matches.
}
else
{
    //Does not match.
}

This matches for forward slash / only. I don't know how to write regex for both slash (for OR condition).

4 Answers
Related