Skip to content

Instantly share code, notes, and snippets.

@aolo2
Created March 22, 2018 14:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aolo2/1f94c4f40d724c876902f6631ab3dbf5 to your computer and use it in GitHub Desktop.
Save aolo2/1f94c4f40d724c876902f6631ab3dbf5 to your computer and use it in GitHub Desktop.
import java.util.regex.*;
public class Lab3 {
private static void test_match(String text) {
String stringLiteral = "`(`{2}|[.\\s])*`";
String numLiteral = "[0-9]+|[01]+b";
String ident = "[\\?\\*\\|][0-9\\?\\*\\|]";
String pattern = "(^" + stringLiteral + ")|(^" + numLiteral + ")|(^" + ident + ")";
Pattern p = Pattern.compile(pattern);
Matcher m = p.matcher(text);
if (m.find()) {
// if (m.group(1) != null)
} else {
System.out.println("ERROR");
}
}
public static void main(String args[]) {
test_match("`123123adsf2323fg2qy3h4wrhpidsrfug89u29jtwgv`");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment