Class RegexUtils


  • public class RegexUtils
    extends Object
    Utility functions for regular expression patterns.
    • Constructor Detail

      • RegexUtils

        public RegexUtils()
    • Method Detail

      • getNamedCaptureGroupsFromPattern

        public static Set<String> getNamedCaptureGroupsFromPattern​(String pattern)
        Extracts the names of the named capture groups found within a regex. This function may return false positives, so you must ensure to guard against IllegalArgumentExceptions when calling Matcher.group(String). Derived from https://stackoverflow.com/questions/15588903/get-group-names-in-java-regex The returned Set preserves the order of capture groups as found in the pattern.
        Parameters:
        pattern - the pattern from which to extract the named capture groups
        Returns:
        an ordered list of named capture group candidates