Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Find a dot in a string
//'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
Find Case Combinations of a String
1.5
Kochergina_1
Check Input
JAVA sidebar pattern match
exp 1
UserDefinedBar
Minimum Vertices to Traverse Directed Graph
1
Vowel Substring