Last active
June 29, 2016 23:10
-
-
Save jido/878ee71ca908366ff193783bbdce0c11 to your computer and use it in GitHub Desktop.
Why is my Matcher not working?
This file contains hidden or 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
private static final Pattern parser = Pattern.compile("/(\\S+)/"); | |
private String parseAction(String tag) { | |
Matcher them = parser.matcher(tag); | |
if (!them.find()) return "YOLO"; | |
return them.group(1); | |
} | |
Result: | |
juin 29, 2016 11:58:24 PM com.bredelet.mistigri.Mistigri prrcess | |
INFOS: tag=<> action=YOLO | |
juin 29, 2016 11:58:24 PM com.bredelet.mistigri.Mistigri prrcess | |
INFOS: tag=<CAPS text="Mistigri"> action=YOLO | |
juin 29, 2016 11:58:24 PM com.bredelet.mistigri.Mistigri prrcess | |
INFOS: tag=<CAPS text="quite friendly"> action=YOLO | |
juin 29, 2016 11:58:24 PM com.bredelet.mistigri.Mistigri prrcess | |
INFOS: tag=<#CAPS> action=YOLO | |
juin 29, 2016 11:58:24 PM com.bredelet.mistigri.Mistigri prrcess | |
INFOS: tag=</CAPS> action=YOLO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Don't put the regex inside / /.