Package easyIO

Class Regex


  • public class Regex
    extends java.lang.Object
    Regular expression support for easyIO.Scanner
    See Also:
    easyIO.Scanner
    • Method Detail

      • scanPattern

        public static void scanPattern​(BacktrackScanner sc,
                                       Recognizer r)
                                throws UnexpectedInput
        Match the input characters starting at the current position against the pattern r and advance the scanner position beyond the matched characters. Throw UnexpectedInput if there is no way to match the input characters against the pattern, and leave the scanner position unchanged.
        Throws:
        UnexpectedInput
      • parsePattern

        public static java.lang.String parsePattern​(BacktrackScanner sc,
                                                    Recognizer r)
                                             throws UnexpectedInput
        Match the input characters starting at the current position against the pattern r and return the characters matched. Throw UnexpectedInput if there is no way to match the input characters against the pattern, and leave the scanner position unchanged.
        Throws:
        UnexpectedInput
      • parseToDelimiter

        public static java.lang.String parseToDelimiter​(BacktrackScanner sc,
                                                        Recognizer delim)
        Return all the characters from the current scanner position up to the first occurrence of the delimiter pattern delim, leaving the scanner position either immediately after that delimiter pattern or at the end of the string if the delimiter pattern was never found.
      • hasPattern

        public static boolean hasPattern​(BacktrackScanner sc,
                                         Recognizer r)
        Whether the next characters on the input can be matched by r.
      • advanceToPattern

        public static void advanceToPattern​(BacktrackScanner sc,
                                            Recognizer r)
        Advance the scanner position to the point where the pattern recognized by r is found, or all the way to the end of the input if it is not found.
      • parseToPattern

        public static java.lang.String parseToPattern​(BacktrackScanner sc,
                                                      Recognizer r)
        Return all the text between the current scanner position and the first occurrence of the pattern recognized by r.
      • opt

        public static Recognizer opt​(Recognizer a)
        Recognizes 0 or 1 instance of a (regular expression a?)
      • repeat

        public static Recognizer repeat​(Recognizer a)
        Recognizes 0 or more instances of a (regular expression a*)
      • oneOrMore

        public static Recognizer oneOrMore​(Recognizer a)
        Recognizes 1 or more instances of a (a+)
      • constant

        public static Recognizer constant​(java.lang.String c)
        Recognizes all of the characters in c, in sequence.
      • anyChar

        public static Recognizer anyChar​(java.lang.String c)
        Recognizer that matches any single character in the string c
      • notChar

        public static Recognizer notChar​(java.lang.String c)
        Recognizer that matches any single character not in the string c.
      • whitespace

        public static Recognizer whitespace()
        Recognizer that matches a single whitespace character.