O'Reilly logo

Building Parsers with Java™ by Steven John Metsker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

8.5. A Regular Expression Parser

The class RegularParser holds a collection of methods that return the subparsers for a regular expression grammar. Figure 8.4 shows this class.

Figure 8.4. The RegularParser class. This class holds a collection of methods that compose into a parser for regular expressions.

To use this class, you can apply RegularParser.start() to match a character assembly. As with the ArithmeticParser class, the RegularParser class provides a value() method, which simplifies using the class. The following example uses the RegularParser class's value() method to match a variety of regular expressions:

 package sjm.examples.regular; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required