Skip to content

Instantly share code, notes, and snippets.

@dbrady
Created July 9, 2011 04:47
Show Gist options
  • Save dbrady/1073325 to your computer and use it in GitHub Desktop.
Save dbrady/1073325 to your computer and use it in GitHub Desktop.
Regex Flipflop Zample
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
@dbrady
Copy link
Author

dbrady commented Jul 9, 2011

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

@phaedryx
Copy link

phaedryx commented Jul 9, 2011

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