import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Example {
public static void main(String[] args) {
final String regex = "(?!\\d\\d)(?![a-zA-Z]{2})(?:(?:>?[:;=%8BXx]['‘’]?[-o*,^ã£]?(?:(?P<mouth>[()|Il])(?P=mouth)*|[\\/0\\]o\\\\D\\[PpSs<>\\{\\}CcOXx*3@ÞþbL&?$#]))|(?:[()\\\\\\{\\}\\/<\\[>\\]DOo0|SsXxlI*@q][-o*,]?['‘’]?[:=8;%Xx]<?))|(?P<head>\\()?(?:(?P<eye>[<>v*.^~=ಠ-])?[_.-](?P=eye)|[o0O][_.-][o0O]|>[_.-]?<)['‘’]?(?(head)\\))|xD|XD|XP|xP|DX|<3|\\^\\^|\\\\o\\/|o\\/|\\\\o";
final String string = ":-) :) :D :o) :] :3 :c) :> =] 8) =) :} :^) :ã£)\n"
+ ":-D 8-D 8D x-D xD X-D XD =-D =D =-3 =3 B^D\n"
+ ":-))\n"
+ ">:[ :-( :( :-c :c :-< :ã£C :< :-[ :[ :{\n"
+ ";(\n"
+ ":-|| :@ >:(\n"
+ ":'-( :'(\n"
+ ":'-) :')\n"
+ "D:< D: D8 D; D= DX v.v D-':\n"
+ ">:O :-O :O :-o :o 8-0 O_O o-o O_o o_O o_o O-O\n"
+ ":* :^* ( '}{' )\n"
+ ";-) ;) *-) *) ;-] ;] ;D ;^) :-,\n"
+ ">:P :-P :P X-P x-p xp XP :-p :p \n"
+ "=p :-Þ :Þ :þ :-þ :-b :b d:\n"
+ ">:\\ >:/ :-/ :-. :/ :\\ =/ =\\ :L =L :S >.<\n"
+ ":| :-|\n"
+ ":$\n"
+ ":-X :X :-# :#\n"
+ "O:-) 0:-3 0:3 0:-) 0:) 0;^)\n"
+ ">:) >;) >:-)\n"
+ "}:-) }:) 3:-) 3:)\n"
+ "o/\\o ^5 >_>^ ^<_<\n"
+ "|;-) |-O\n"
+ ":-& :&\n"
+ "#-)\n"
+ "%-) %)\n"
+ "<:-|\n"
+ "ಠ_ಠ\n"
+ "\\o/\n"
+ "*\\0/*\n"
+ "(>_<)\n"
+ "~_~\n"
+ "-.-'\n"
+ "(=_=)\n\n\n";
final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
final Matcher matcher = pattern.matcher(string);
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));
}
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Java, please visit: https://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html