Class Matchers


  • public class Matchers
    extends java.lang.Object
    Utilities for regular expression matchers.
    Author:
    Garret Wilson
    • Constructor Summary

      Constructors 
      Constructor Description
      Matchers()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int[] getIntGroups​(java.util.regex.Matcher matcher)
      Returns an array of integer versions from the available groups of the given matcher.
      static int[] getIntGroups​(java.util.regex.Matcher matcher, int beginGroupNumber)
      Returns an array of integer versions from the available groups of the given matcher, starting at the requested group number.
      • Methods inherited from class java.lang.Object

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

      • Matchers

        public Matchers()
    • Method Detail

      • getIntGroups

        public static int[] getIntGroups​(java.util.regex.Matcher matcher)
        Returns an array of integer versions from the available groups of the given matcher. null groups will be counted as zero. That is, if a matcher contains groups "2", "3", and "null", the array {2, 3, 0} will be returned.
        Parameters:
        matcher - The matcher for which an integer array of group values should be returned.
        Returns:
        An array of integers representing the integer values of the matcher groups.
        Throws:
        java.lang.IllegalArgumentException - if one of the matcher's groups is not null and cannot be parsed as an integer.
      • getIntGroups

        public static int[] getIntGroups​(java.util.regex.Matcher matcher,
                                         int beginGroupNumber)
        Returns an array of integer versions from the available groups of the given matcher, starting at the requested group number. null groups will be counted as zero. That is, if a matcher contains groups "2", "3", and "null", the array {2, 3, 0} will be returned.
        Parameters:
        matcher - The matcher for which an integer array of group values should be returned.
        beginGroupNumber - The one-based group number at which to begin retrieving values.
        Returns:
        An array of integers representing the integer values of the matcher groups.
        Throws:
        java.lang.IllegalArgumentException - if one of the matcher's groups is not null and cannot be parsed as an integer.