Last active
February 12, 2022 12:40
-
-
Save agtokty/c9b1f6bc9fb56bd022f2819ee0e8dcf9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RegexText { | |
public static void main(String[] args) { | |
final String[] testStrings = { | |
"v2/rt.do.reg1/t", // Match | |
"v2/a1.b2.c2/t", // Match | |
"v2/a1;b2;c2/t", // Match | |
"v2/a1-b2-c2/t", // Match | |
"v3/rt.do.reg1/t", // Not Match | |
"v2/rt.do.reg1/t2", // Not Match | |
"v2/rt.do.reg1/t/" // Not Match | |
}; | |
final String regex = "^v2\\/(.*)\\/t$"; | |
final Pattern pattern = Pattern.compile(regex); | |
for (String input : testStrings) { | |
Matcher matcher = pattern.matcher(input); | |
if (matcher.matches()) { | |
System.out.println("Match: " + input); | |
} else { | |
System.out.println("Not Match: " + input); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment