Created
July 9, 2011 04:47
-
-
Save dbrady/1073325 to your computer and use it in GitHub Desktop.
Regex Flipflop Zample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DATA.each_line do |line| | |
puts line if line =~ /metasyntactic/ .. line =~ /regular/ | |
end | |
__END__ | |
blah | |
blarg | |
bleem | |
here are some metasyntactic variables | |
foo | |
bar | |
baz | |
bax | |
qux | |
quux | |
quuux | |
and now back to the regular stuff | |
snouk | |
queem | |
arglebargle |
A little bit more, so you can see the flip-flop: https://gist.github.com/bace5b2cb0916dec43c9
Very cool Dave, thanks for sharing.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output:
22:46:59 dbrady@davepro:~ ruby-1.9.2-p180
∫ ruby zample.rb
here are some metasyntactic variables
foo
bar
baz
bax
qux
quux
quuux
and now back to the regular stuff