Skip to content

Instantly share code, notes, and snippets.

Created April 27, 2013 18:21
Show Gist options
  • Save anonymous/5a94c4512081960304f7 to your computer and use it in GitHub Desktop.
Save anonymous/5a94c4512081960304f7 to your computer and use it in GitHub Desktop.
I am trying to look through a text file and return 1 if the file contains the string "attach" on a line that doesn't start with >. Otherwise return 0
#test case - should return a 0
#> asdf asdfkla sdfaklsd fasd lfaslk fa
#> asdlfka sdfkl asdfkl asflka sflkasjd flkasdjf
#> askldfj asdlfk asdlfk asdlf kasdk lfas dlkfasdf
#>attach aslkdfjasdfl asdf asldkf asd
#asdfkljas d
#test case - should return a 1
#fakdjfksjf attach
#>dkjfakjf dkfdjaf
text = IO.read(ARGV[0])
if text =~ /^>.*(?=.*)attach/
exit 1
else
exit
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment