Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static int goNextChar(String input) {
- for (int i = 0; i < input.length(); i++) {
- char temp = input.charAt(i);
- if (Character.isAlphabetic(temp)) {
- return i;
- }
- }
- return - 1;
- }
- static boolean compare(String inp, String expr) {
- if(inp.length() == 0 && expr.length() == 0) return true;
- int counter = 0;
- for (int i = 0; i < expr.length(); i++) {
- if(expr.charAt(i)== '?') counter ++;
- }
- if(counter == inp.length()) return true;
- else if (counter > inp.length()) return false;
- if(expr.contains("*")) return true;
- return false;
- }
- static boolean ifEquals(String inp, String expr) {
- if(inp.equals(expr)) return true;
- return false;
- }
- static boolean isSame(String inp, String expr) {
- int indexNextChar = goNextChar(expr);
- if (indexNextChar < 0 ) {
- return compare(inp, expr);
- }
- char nextChar = expr.charAt(indexNextChar);
- for (int i = 0; i < inp.length(); i++) {
- if (inp.charAt(i) == nextChar) {
- if(isSame(inp.substring(0,i),
- expr.substring(0, indexNextChar))
- &&
- isSame(trimarator(inp, i + 1 , inp.length()),
- trimarator(expr, indexNextChar + 1, expr.length()))) return true;
- }
- }
- return false;
- }
- static String trimarator(String word, int inOne, int twoInd) {
- if (inOne >= twoInd || inOne < 0 ) return "";
- return word.substring(inOne,twoInd);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement