An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20110401/a900de16/attachment.pl>
regular expression
2 messages · array chip, Henrique Dallazuanna
Try this also:
grep("arg", "arg.symptom", value = TRUE, invert = TRUE)
character(0)
grep("arg", "liver.symptom", value = TRUE, invert = TRUE)
[1] "liver.symptom"
On Fri, Apr 1, 2011 at 1:33 PM, array chip <arrayprofile at yahoo.com> wrote:
Great. thank you Bernd! Learned a new thing here. John
________________________________
From: Bernd Weiss <bernd.weiss at uni-koeln.de>
Cc: r-help at r-project.org
Sent: Thu, March 31, 2011 6:19:25 PM
Subject: Re: [R] regular expression
Am 31.03.2011 21:06, schrieb array chip:
Ok then this code didn't do what I wanted. I want "not including
'arg' before '.symptom'", not individual letters of "arg", but rather
as a word.
Bill Dunlap suggested using invert=T, it works for single 1
condition, but not for 2 conditions here: not including "arg" before
".", but at the same time, does include ".symptom".
Any other suggestions would be appreciated
This does work (but I am by no means an expert in regex...). I am using
'negative lookbehind'[1] to define an expression like 'arg'.
grep('(?<!(arg))\\.symptom',"arg.symptom",value=T, perl = T)
character(0)
grep('(?<!(arg))\\.symptom',"liver.symptom",value=T, perl = T)
[1] "liver.symptom"
Bernd
[1] http://www.regular-expressions.info/lookaround.html
? ? ? ?[[alternative HTML version deleted]]
______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Henrique Dallazuanna Curitiba-Paran?-Brasil 25? 25' 40" S 49? 16' 22" O