!cat zen.txt %%script perl open (ZENFILE, 'zen.txt'); while () { print if /never/; } %%script perl open (ZENFILE, 'zen.txt'); while () { print if /is better than/; } %%script perl open (ZENFILE, 'zen.txt'); while () { print if /simple/; } %%script perl open (ZENFILE, 'zen.txt'); while () { print if /simple/i; } %%script perl open (ZENFILE, 'zen.txt'); while () { print if / ... /; } %%script perl open (ZENFILE, 'zen.txt'); while () { print "$1\n" if / (...) /; } %%script perl open (ZENFILE, 'zen.txt'); while () { if (/(....) to (.....)/) { print; print "$1, $2\n"; } } %%script perl open (ZENFILE, 'zen.txt'); while () { if (/(.*) to (.*)/) { print; print "$1, $2\n"; } } %%script perl open (ZENFILE, 'zen.txt'); while () { print "$1\n" if / ([aeiou].....) /i; } %%script perl open (ZENFILE, 'zen.txt'); while () { print "$1\n" if / ([aeiou][^ ]*) /i; } %%script perl open (ZENFILE, 'zen.txt'); while () { if (/([^ ]*) to ([^ ]*)/) { print; print "$1, $2\n"; } } %%script perl open (ZENFILE, 'zen.txt'); while () { if (/([a-z]*) to ([a-z]*)/) { print; print "$1, $2\n"; } } %%script perl open (ZENFILE, 'zen.txt'); while () { if (/([\w]*) to ([\w]*)/) { print; print "$1, $2\n"; } } %%script perl open (ZENFILE, 'zen.txt'); while () { $_ =~ s/is/might be/; print $_; } %%script perl open (ZENFILE, 'zen.txt'); while () { $_ =~ s/ (\w*) to / \1, really very \1, to /; print $_; } %%script perl open (ZENFILE, 'zen.txt'); while () { if (/ to /) { print print split / /; } } %%script perl $data = "I can be reached at (937) 395-2343 or 122-4235, unless it's raining." if ($data =~ /\d+-\d+/ %%script perl open (ZENFILE, 'zen.txt'); while () { if (/(\b[A-Z][a-z]+\b)/) { print $1; print "\n"; } } %%script perl open (ZENFILE, 'zen.txt'); while () { if (/ # Capitalized word detector ( # capture the result in $1 \b # word boundary [A-Z] # one capital letter [a-z]+ # one or more lowercase letters \b # word boundary ) # end captured group /x) { print $1; print "\n"; } } from verbalexpressions import VerEx verbal_expression = VerEx() # Create an example of how to test for correctly formed URLs verbal_expression = VerEx() tester = (verbal_expression. start_of_line(). find('http'). maybe('s'). find('://'). maybe('www.'). anything_but(' '). end_of_line() ) tester.source() tester.match("https://www.google.com") tester.match("my nifty website") result = tester.match("https://www.google.com") result.groups() VerEx().anything().source() VerEx().find('cows').match('how do you like Cows?') ve2 = VerEx().find("ftp").or().find("http").maybe("s").then("://") from regexpbuilder.RegExpBuilder import RegExpBuilder builder1 = (RegExpBuilder() .find("$") .min(1).digits() .then(".") .digit() .digit()) builder1.search("is there money in $2.22?") money = builder1.get_regexp() result = money.search("is there money in $2.22?") result result.group(0) discount = (RegExpBuilder() .find("was").then(money) .maybe(",").find("now").then(money) ) money type(money)