Perform basic regex matching with Joni
masterTo perform a regex match, create a Regex object using a byte array pattern, an offset, a length, an Option, and an encoding (typically UTF8Encoding.INSTANCE). Then, create a Matcher from that regex and use matcher.search() to find the pattern within a target byte array. search() returns the starting index of the match, or -1 if no match is found.
byte[] pattern = "a*".getBytes();
byte[] str = "aaa".getBytes();
Regex regex = new Regex(pattern, 0, pattern.length, Option.NONE, UTF8Encoding.INSTANCE);
Matcher matcher = regex.matcher(str);
int result = matcher.search(0, str.length, Option.DEFAULT);