public static void main ( String [ ] args ) { Scanner scan = new Scanner ( System . in ) ; RegularExpression < String > regex = RegularExpressionParsers . word . parse ( args [ 0 ] ) ; System . out . println ( "regex: " + regex ) ; System . out . println ( ) ; while ( scan . hasNextLine ( ) ) { String line = scan . nextLine ( ) ; System . out . println ( "contains: " + regex . apply ( Arrays . asList ( line . split ( "\\s+" ) ) ) ) ; System . out . println ( "matches: " + regex . matches ( Arrays . asList ( line . split ( "\\s+" ) ) ) ) ; System . out . println ( ) ; } scan . close ( ) ; }
An interactive program that compiles a word - based regular expression specified in arg1 and then reads strings from stdin evaluating them against the regular expression .