grep("^[ \t]", x)String manipulation:
which(!is.na(match(substring(x, 1, 1), c(" ", "\t"))))
gsub("^From", "X-From:", h[1])String manipulation:
if(sustring(h[1], 1, 4) == "From") h[1] = paste("X-From:", substring(h[1], 5), sep="")
Content-Type: multipart/mixed; boundary="----ack1234"
for <jm@localhost>; Thu, 25 Jul 2002 06:05:36 -0400 (EDT)
Feb 3 23:41:18 jessie sendmail[16406]: [ID 801593 mail.info] i144fID8016406: from=<EEQXMCKJDFP@charter.com>, size=13570, class=0, nrcpts=1, msgid=<JXHYECDLQWVAEUZKFHGGTET@verizon.net>, proto=ESMTP, daemon=MTA, relay=guard.research.bell-labs.com [135.104.2.10]
Feb 3 23:41:19 jessie imapd[16410]: [ID 806292 mail.debug] imap service init from 135.104.12.62
Feb 3 23:41:19 jessie imapd[16410]: [ID 234311 mail.info] Login user=kc host=kc-lap.research.bell-labs.com [135.104.12.62]
Feb 3 23:41:19 jessie sendmail[16407]: [ID 801593 mail.info] i144fID8016406: to=<iis@jessie.research.bell-labs.com>, delay=00:00:01, xdelay=00:00:00, mailer=local, pri=43820, dsn=2.0.0, stat=Sent
Feb 3 23:41:49 jessie imapd[16410]: [ID 533678 mail.info] Logout user=kc host=kc-lap.research.bell-labs.com [135.104.12.62]
Feb 3 23:42:19 jessie imapd[16476]: [ID 806292 mail.debug] imap service init from 135.104.12.62
Feb 3 23:42:19 jessie imapd[16476]: [ID 234311 mail.info] Login user=kc host=kc-lap.research.bell-labs.com [135.104.12.62]
Feb 3 23:42:29 jessie sendmail[16478]: [ID 801593 mail.info] i144gTD8016478: from=<fE@henly.f9.co.uk>, size=7141, class=0, nrcpts=1, msgid=<b17f01c3ead8$1ae6f34b$4f6f7a11@S08aYfV>, bodytype=8BITMIME, proto=ESMTP, daemon=MTA, relay=guard.research.bell-labs.com [135.104.2.10]
Feb 3 23:42:29 jessie sendmail[16479]: [ID 801593 mail.info] i144gTD8016478: to=<mitra@jessie.research.bell-labs.com>, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=37394, dsn=2.0.0, stat=Sent
Feb 3 23:42:37 jessie sendmail[16488]: [ID 801593 mail.info] i144gbD8016488: from=<owner-lds-gems@LISTS.LDS.ORG>, size=2896, class=0, nrcpts=1, msgid=<5.1.1.6.2.20040203062440.02c045e0@mail.mstar.net>, proto=ESMTP, daemon=MTA, relay=guard.research.bell-labs.com [135.104.2.9]
Feb 3 23:42:37 jessie sendmail[16489]: [ID 801593 mail.info] i144gbD8016488: to=<nuzman@jessie.research.bell-labs.com>, delay=00:00:00, xdelay=00:00:00, mailer=local, pri=33139, dsn=2.0.0, stat=Sent
169.237.46.168 - - [26/Jan/2004:10:47:58 -0800] "GET /stat141/Winter04 HTTP/1.1" 301 328 "http://anson.ucdavis.edu/courses/" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322)"
169.237.46.168 - - [26/Jan/2004:10:47:58 -0800] "GET /stat141/Winter04/ HTTP/1.1" 200 2585 "http://anson.ucdavis.edu/courses/" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322)"
169.237.46.168 - - [26/Jan/2004:10:47:58 -0800] "GET /stat141/Winter04/Class.css HTTP/1.1" 404 1227 "http://winnie.ucdavis.edu/stat141/Winter04/" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322)"
169.237.46.168 - - [26/Jan/2004:10:47:58 -0800] "GET /stat141/Winter04/ucd1.gif HTTP/1.1" 200 6122 "http://winnie.ucdavis.edu/stat141/Winter04/" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322)"
169.237.46.168 - - [26/Jan/2004:10:48:06 -0800] "GET /stat141/Winter04/annnouncements.htm HTTP/1.1" 404 1227 "http://winnie.ucdavis.edu/stat141/Winter04/" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322)"
169.237.46.168 - - [26/Jan/2004:10:48:07 -0800] "GET /stat141/Winter04/Class.css HTTP/1.1" 404 1227 "http://winnie.ucdavis.edu/stat141/Winter04/" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322)"
169.237.46.173 - - [26/Jan/2004:11:03:07 -0800] "GET /stat141/Winter04/discussion2.html HTTP/1.1" 404 1056 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)"
169.237.46.173 - - [26/Jan/2004:11:03:12 -0800] "GET /stat141/Winter04/ HTTP/1.1" 200 2585 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)"
169.237.46.173 - - [26/Jan/2004:11:03:12 -0800] "GET /stat141/Winter04/Class.css HTTP/1.1" 404 1227 "http://winnie.ucdavis.edu/stat141/Winter04/" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)"
169.237.46.173 - - [26/Jan/2004:11:03:12 -0800] "GET /stat141/Winter04/ucd1.gif HTTP/1.1" 200 6122 "http://winnie.ucdavis.edu/stat141/Winter04/" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)"
169.237.46.173 - - [26/Jan/2004:11:03:15 -0800] "GET /stat141/Winter04/handouts.html HTTP/1.1" 200 558 "http://winnie.ucdavis.edu/stat141/Winter04/" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)"
169.237.46.173 - - [26/Jan/2004:11:03:17 -0800] "GET /stat141/Winter04/Handouts/discussion2.html HTTP/1.1" 200 6100 "http://winnie.ucdavis.edu/stat141/Winter04/handouts.html" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)"
169.237.46.173 - - [26/Jan/2004:11:03:20 -0800] "GET /stat141/Winter04/Handouts/discussion3.html HTTP/1.1" 200 3003 "-" "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.1.4322)"
169.237.99.188 - - [26/Jan/2004:11:03:47 -0800] "GET /stat141/Winter04 HTTP/1.1" 301 328 "http://www.stat.ucdavis.edu/courses/" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20030120"
gsub("^From", "X-From:", h[1])
grep("^$", x)
proxy-6.daimler-benz.com - - [29/Dec/2003:06:35:48 -0600] "GET /R.css HTTP/1.1" 304 -
grep("-$", x)
220.73.165.205 - - [29/Dec/2003:06:33:01 -0600] "HEAD /src/contrib/xtable_1.1-2.tar.gz HTTP/1.0" 404 0
grep(" 0$", x)
> regexpr("\\^", "This has a caret ^.")
220.73.165.205 - - [29/Dec/2003:06:33:01 -0600] "HEAD /src/contrib/xtable_1.1-2.tar.gz HTTP/1.0" 404 0
grep("[ \t]0$", x)
regexpr("a", "this is a sentence")
regexpr("a*", "this is aaaa sentence")
regexpr("a?", "this is a sentence")
regexpr("f+", "aardvark")
grep("(ACT|GG){2,5}", genes)
regexpr("([a-z]+) \\1", c("Ha a sentence", "with the the?", "notnot here", "with the they","no match"))
regexpr("(\\<[a-z]+\\>) \\<\\1\\>", c("Ha a sentence", "with the the?", "notnot here", "with the they", "no match"))
gsub("from", "to", "Note from bob")
193.188.97.151 - - [29/Dec/2003:06:36:18 -0600] "GET /logo.html HTTP/1.1" 200 244
193.188.97.151, 29/Dec/2003:06:36:18, /logo.html, 200, 244
(.*) - - \\[(.*) [-+][0-9]+\\] "(GET|POST) (.*) (HTTP|FTP)(/1.[01])?" ([0-9]+) (-|[0-9]+)
\\1,\\2,\\4,\\7,\\8
gsub("<.*>", "", 'URL: <a href="http://www.bob.org"><i>Bob</i></a><p>') [1] "URL: "
gsub("<[^<]*>", "", 'URL: <a href="http://www.bob.org"><i>Bob</i></a><p>') [1] "URL: Bob"