Skip to content

regular expressions

2 messages · GOUACHE David, Christos Hatzis

#
Hello all,
 
Still fighting with regular expressions and such, I am again stuck:
 
Suppose I have a vector of character chains. In this vector, I wish to identify which character chains start with a given pattern, and then replace everything that comes after said pattern.
 
Here is a quick example :
 
words<-c("plifboum","plafboum","ploufbang","plifplaf")
 
I want to end up with something like this:
 
"plifONE","plafboum","ploufbang","plifONE"
 
All I can produce so far is this :
gsub("\\bplif.","ONE",words,perl=T)
 
which turns out :
"ONEboum","plafboum","ploufbang","ONEplaf"
 
Thanks in advance for your help.
 
David Gouache

Arvalis - Institut du V?g?tal

Station de La Mini?re

78280 Guyancourt

Tel: 01.30.12.96.22 / Port: 06.86.08.94.32
#
Try this one:
[1] "plifONE"   "plafboum"  "ploufbang" "plifONE"  

-Christos