Code Comments
Programming Forum and web based access to our favorite programming groups.What's the easiest way to match regexp in an entire .txt file against a set of keywords? For example, a script that would search an e-mail for the words "hello" "computer" "johnny" and then return the results? Sorry if this question is a bit obtuse, I merely exploring an idea... Thanks. downview
Post Follow-up to this messageYou could load the whole file into a string and go from there or, if it is a big big file, read it in one line at a time. As far as the matching part, I have asked for help on this topic in the past so maybe a few links to recent discussion might help: http://groups-beta.google.com/group...r /> archnow%3 DSearch+this+group%26&_doneTitle=Back+to+Search&&d#57ac337ed73b655f http://groups-beta.google.com/group...r /> 0caf2c9d4 45a9258
Post Follow-up to this messageA Down View (downview@gmail.com) wrote on MMMMCXXXVI September MCMXCIII
in <URL:news:1104184278.392223.79670@z14g2000cwz.googlegroups.com>:
'' What's the easiest way to match regexp in an entire .txt file against a
'' set of keywords?
''
'' For example, a script that would search an e-mail for the words "hello"
'' "computer" "johnny" and then return the results?
''
'' Sorry if this question is a bit obtuse, I merely exploring an idea...
'' Thanks.
$ grep 'hello|computer|johnny' e.mail
Or:
$ for w in hello computer johnny; do grep $w e.mail; done
Abigail
--
#!/opt/perl/bin/perl -w
$\ = $"; $; = $$; END {$: and print $:} $SIG {TERM} = sub {$ := $_}; kill 15
=>
fork and ($; == getppid and exit or wait) foreach qw /Just another Perl Hack
er/
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.