Re: [R] regular expression

From: array chip <>
Date: Fri, 01 Apr 2011 09:33:57 -0700 (PDT)

Great. thank you Bernd! Learned a new thing here.


From: Bernd Weiss <>

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)

> grep('(?<!(arg))\\.symptom',"liver.symptom",value=T, perl = T)
[1] "liver.symptom"



        [[alternative HTML version deleted]] mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Fri 01 Apr 2011 - 16:35:59 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 01 Apr 2011 - 17:30:25 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive