Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Matcher Example (not my)
//'main' method must be in a class 'Rextester'. //Compiler version 1.8.0_111 import java.util.*; import java.lang.*; import java.util.regex.Matcher; import java.util.regex.Pattern; class Rextester { final static String regex = "^[\\/\\.].*$"; final static String[] stringsToTest = { ".file", "./file", "/file", "/.file", ".", "./", "/some/path", "/some-path/.some-file", "/path/path/.file", "/path/.file", "/asfas/.d", "/path/.file" }; final static Pattern pattern = Pattern.compile(regex); public static void main(String[] args) { for (String text : stringsToTest) { testRegex(text); } } public static void testRegex(String testString) { Matcher matcher = pattern.matcher(testString); while (matcher.find()) { System.out.println("Full match: " + matcher.group(0)); for (int i = 1; i <= matcher.groupCount(); i++) { System.out.println("Group " + i + ": " + matcher.group(i)); } } } }
run
|
edit
|
history
|
help
0
3
3.D
java polymorhism
Class multiple
First Interview question - Java
Main
contoh 43
Coding Numbers - Polindrome
1d
Решето Эратосфена