Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static boolean matches(String s, String p, int sIndex, int pIndex) {
- if (sIndex == s.length() || pIndex == p.length()) {
- return true;
- }
- if (p.toCharArray()[pIndex] == '*' && sIndex == s.length()
- && pIndex != p.length()) {
- return false;
- }
- if (p.toCharArray()[pIndex] == '?') {
- return matches(s, p, ++sIndex, ++pIndex);
- } else if (s.toCharArray()[sIndex] == p.toCharArray()[pIndex]) {
- return matches(s, p, ++sIndex, ++pIndex);
- } else if (p.toCharArray()[pIndex] == '*') {
- return matches(s, p, ++sIndex, pIndex)
- || matches(s, p, ++sIndex, ++pIndex);
- } else {
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement