Class RegexUtils


  • public class RegexUtils
    extends java.lang.Object
    Utility functions for regular expression patterns.
    • Constructor Summary

      Constructors 
      Constructor Description
      RegexUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Set<java.lang.String> getNamedCaptureGroupsFromPattern​(java.lang.String pattern)
      Extracts the names of the named capture groups found within a regex.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • RegexUtils

        public RegexUtils()
    • Method Detail

      • getNamedCaptureGroupsFromPattern

        public static java.util.Set<java.lang.String> getNamedCaptureGroupsFromPattern​(java.lang.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