This highlights the literal meaning of the last ] in your correct_brackets:
aff <- c("affgfk]ing", "fgok", "rafgkah]e","a fgk", "bafghk]")
To me, too, the missing_brackets looks more like what was desired, and
returns correct results for a PCRE. Perhaps the regular expression
should have been re
On 4/28/20 2:29 AM, Sigbert Klinke wrote:
Hi,
we gave students the task to construct a regular expression selecting
some texts. One send us back a program which gives different results
on stringr::str_view and grep.
The problem is "[^[A-Z]]" / "[^[A-Z]" at the end of the regular
expressio
Hi,
we gave students the task to construct a regular expression selecting
some texts. One send us back a program which gives different results on
stringr::str_view and grep.
The problem is "[^[A-Z]]" / "[^[A-Z]" at the end of the regular
expression. I would have expected that all four calls
> On Oct 9, 2017, at 6:08 PM, Georges Monette wrote:
>
> How about this (I'm showing it as a pipe because it's easier to read that
> way):
>
> library(magrittr)
> "f 147/1315/587 2820/1320/587 3624/1321/587 1852/1322/587" %>%
> strsplit(' ') %>%
> unlist %>%
> sub('^[^/]*/*','',.) %>%
>
How about this (I'm showing it as a pipe because it's easier to read
that way):
library(magrittr)
"f 147/1315/587 2820/1320/587 3624/1321/587 1852/1322/587" %>%
strsplit(' ') %>%
unlist %>%
sub('^[^/]*/*','',.) %>%
sub('^[^/]*/*','',.) %>%
paste(collapse = ' ')
Georges Monette
--
Geo
On 09/10/2017 12:06 PM, William Dunlap wrote:
"(^| +)([^/ ]*/?){0,2}", with the first "*" replaced by "+" would be a
bit better.
Thanks! I think I actually need the *, because theoretically the b part
of the word could be empty, i.e. "a//c" would be legal and should become
"c".
Duncan Murd
On 09/10/2017 11:23 AM, Ulrik Stervbo wrote:
Hi Duncan,
why not split on / and take the correct elements? It is not as elegant
as regex but could do the trick.
Thanks for the suggestion. There are likely many thousands of lines of
data like the two real examples (which had about 5000 and 60
"(^| +)([^/ ]*/?){0,2}", with the first "*" replaced by "+" would be a bit
better.
Bill Dunlap
TIBCO Software
wdunlap tibco.com
On Mon, Oct 9, 2017 at 8:50 AM, William Dunlap wrote:
> > x <- "f 147/1315/587 2820/1320/587 3624/1321/587 1852/1322/587"
> > gsub("(^| *)([^/ ]*/?){0,2}", "\\1", x)
>
> x <- "f 147/1315/587 2820/1320/587 3624/1321/587 1852/1322/587"
> gsub("(^| *)([^/ ]*/?){0,2}", "\\1", x)
[1] " 587 587 587 587"
> y <- "aa aa/ aa/bb aa/bb/ aa/bb/cc aa/bb/cc/ aa/bb/cc/dd aa/bb/cc/dd/"
> gsub("(^| *)([^/ ]*/?){0,2}", "\\1", y)
[1] "cc cc/ cc/dd cc/dd/"
Bill Dunlap
TIBCO Sof
> On 9 Oct 2017, at 17:02 , Duncan Murdoch wrote:
>
> I have a file containing "words" like
>
>
> a
>
> a/b
>
> a/b/c
>
> where there may be multiple words on a line (separated by spaces). The a, b,
> and c strings can contain non-space, non-slash characters. I'd like to use
> gsub() to
Hi Duncan,
You can try this:
library(readr)
f <- function(s) {
t <- unlist(readr::tokenize(paste0(gsub(" ",",",s),"\n",collapse="")))
i <- grep("[a-zA-Z0-9]*/[a-zA-Z0-9]*/",t)
u <- sub("[a-zA-Z0-9]*/[a-zA-Z0-9]*/","",t[i])
paste0(u,collapse=" ")
}
f("f 147/1315/587 2820/1320/587 3624/1321
Hi Duncan,
why not split on / and take the correct elements? It is not as elegant as
regex but could do the trick.
Best,
Ulrik
On Mon, 9 Oct 2017 at 17:03 Duncan Murdoch wrote:
> I have a file containing "words" like
>
>
> a
>
> a/b
>
> a/b/c
>
> where there may be multiple words on a line (se
I have a file containing "words" like
a
a/b
a/b/c
where there may be multiple words on a line (separated by spaces). The
a, b, and c strings can contain non-space, non-slash characters. I'd
like to use gsub() to extract the c strings (which should be empty if
there are none).
A real exa
Dear Enrico,
Many thanks and Best Regards,
Ashim.
On Thu, Jun 8, 2017 at 5:11 PM, Enrico Schumann
wrote:
>
> Zitat von Ashim Kapoor :
>
>
> Dear All,
>>
>> My query is:
>>
>> Do we always need to use perl = TRUE option when doing ignore.case=TRUE?
>>
>> A small example :
>>
>> my_text =
>> "RE
Zitat von Ashim Kapoor :
Dear All,
My query is:
Do we always need to use perl = TRUE option when doing ignore.case=TRUE?
A small example :
my_text =
"RECOVERY OFFICER-II\nDEBTS RECOVERY TRIBUNAL-III\n RC No. 162/2015\nSBI
VS RAMESH GUPTA.\nDated: 01.03.2016 Item no.01
Dear All,
My query is:
Do we always need to use perl = TRUE option when doing ignore.case=TRUE?
A small example :
my_text =
"RECOVERY OFFICER-II\nDEBTS RECOVERY TRIBUNAL-III\n RC No. 162/2015\nSBI
VS RAMESH GUPTA.\nDated: 01.03.2016 Item no.01\n
Present: Ms. Sonakshi, t
uary 14, 2015 at 8:47 AM
To: dh m mailto:macque...@llnl.gov>>
Cc: Mark Leeds mailto:marklee...@gmail.com>>,
"r-help-stat.math.ethz.ch"
mailto:r-h...@stat.math.ethz.ch>>
Subject: Re: [R] regular expression question
On Wed, Jan 14, 2015 at 10:03 AM, MacQueen, Don
m
On Wed, Jan 14, 2015 at 10:03 AM, MacQueen, Don wrote:
> I know you already have a couple of solutions, but I would like to mention
> that it can be done in two steps with very simple regular expressions. I
> would have done:
>
> s <- c("lngimbintrhofixed","lngimbnointnorhofixed","test",
>
I know you already have a couple of solutions, but I would like to mention
that it can be done in two steps with very simple regular expressions. I
would have done:
s <- c("lngimbintrhofixed","lngimbnointnorhofixed","test",
'rhofixedtest','norhofixedtest')
res <- gsub('norhofixed$', '',s)
r
Hi Mark,
Mark Leeds writes:
> Hi All: I have a regular expression problem. If a character string ends
> with "rhofixed" or "norhofixed", I want that part of the string to be
> removed. If it doesn't end with either of those two endings, then the
> result should be the same as the original. Below
No HTML please. it makes me itchy!
> s <- c("lngimbintrhofixed","lngimbnointnorhofixed","test")
> sub('(no)?rhofixed$','',s)
[1] "lngimbint" "lngimbnoint" "test"
>
On Mon, Jan 12, 2015 at 1:37 PM, Mark Leeds wrote:
> Hi All: I have a regular expression problem. If a character string ends
>
Hi All: I have a regular expression problem. If a character string ends
with "rhofixed" or "norhofixed", I want that part of the string to be
removed. If it doesn't end with either of those two endings, then the
result should be the same as the original. Below doesn't work for the
second case. I kn
, 29 Jun 2014 13:16:26 -0700
> Subject: Re: [R] regular expression help
> To: bac...@hotmail.com
> CC: dwinsem...@comcast.net; r-help@r-project.org
>
>> what's the difference between [:space:]+ and[[:space:]]+ ?
>
> The pattern '[:space:]' matches any of
ace:]+ instead
> of [[:space:]]+
> what's the difference between [:space:]+ and[[:space:]]+ ?
>
> Thanks so much!
> Lin
>
>
>> From: wdun...@tibco.com
>> Date: Fri, 27 Jun 2014 02:35:54 -0700
>> Subje
ring you
> are testing
> so try this
>
> grep('[/]*\\[/]*',test)
>
> Duncan
>
> Duncan Mackay
> Department of Agronomy and Soil Science
> University of New England
> Armidale NSW 2351
> Email: home: mac...@northnet.com.au
>
> -Original Message
!
Lin
> From: wdun...@tibco.com
> Date: Fri, 27 Jun 2014 02:35:54 -0700
> Subject: Re: [R] regular expression help
> To: dwinsem...@comcast.net
> CC: bac...@hotmail.com; r-help@r-project.org
>
> You can use parentheses to factor out the common string in David's
>
ry this
>>>
>>> grep('[/]*\\[/]*',test)
>>>
>>> Duncan
>>>
>>> Duncan Mackay
>>> Department of Agronomy and Soil Science
>>> University of New England
>>> Armidale NSW 2351
>>> Email: home: mac...@northnet.com.a
D1$|^AARSD1', test)
> grepl('^AARSD1//$|^AARSD1 //$|^//AARSD1$|^AARSD1$', test)
[1] FALSE FALSE TRUE TRUE TRUE TRUE
--
David.
>
> Thanks,
> Lin
>
>
>> From: dulca...@bigpond.com
>> To: bac...@hotmail.co
7;//AARSD1','AARSD1');
I want to match only 'AARSD1//','AARSD1 //','//AARSD1','AARSD1'
Thanks,
Lin
------------
> From: dulca...@bigpond.com
> To: bac...@hotmail.com; r-help@r-project.org
> Subject: RE: [R] r
al Message-
From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
Behalf Of C Lin
Sent: Friday, 27 June 2014 10:05
To: r-help@r-project.org
Subject: [R] regular expression help
Dear R users,
I need to match a string. It can be followed or preceded by whitespace or //
or no
Dear R users,
I need to match a string. It can be followed or preceded by whitespace or // or
nothing.
How do I code it in R?
For example:
test <- c('AARSD11','AARSD1-','AARSD1//','AARSD1 //','//AARSD1');
grep('AARSD1(\\s*//*)',test);
should return 3,4,5 and 6.
Thanks in advance for your help.
Hi everybody,
I am developing some functions that use regular expressions
and grepl, to check whether certain strings match a given pattern or not.
In the regular expression I use some shortcuts such as [:alnum:].
Reading the documentation for regular expression there is one sentence that
is not
ibco.com
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
> Behalf
> Of luofeiyu
> Sent: Sunday, December 29, 2013 3:42 AM
> To: R-help@r-project.org
> Subject: [R] why the "[^\\d]" is not equal to "[^
gregexpr(pattern="[^0-9]","+12345ty")
[[1]]
[1] 1 7 8
attr(,"match.length")
[1] 1 1 1
attr(,"useBytes")
[1] TRUE
gregexpr(pattern="[^\\d]","+12345ty")
[[1]]
[1] 1 2 3 4 5 6 7 8
attr(,"match.length")
[1] 1 1 1 1 1 1 1 1
attr(,"useBytes")
[1] TRUE
why the pattern `[^\\d]` has no same effect as of `[
3 11:08 AM
To: Lopez, Dan; R help (r-help@r-project.org)
Subject: Re: [R] Regular Expression returning unexpected results
Please read and follow the Posting Guide, in particular re plain text email.
You need to keep in mind that the characters in literal strings in R source
have to make it into
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352
-Original Message-
From: r-help-boun...@r-project.org
[mailto:r-help-boun...@r-project.org] On Behalf Of Lopez, Dan
Sent: Tuesday, October 29, 2013 12:13 PM
To: R help (r-help@r-project.org)
Subject: [R] Regular
Please read and follow the Posting Guide, in particular re plain text email.
You need to keep in mind that the characters in literal strings in R source
have to make it into RAM before the regex code can parse it. Since regex needs
a single backslash to escape normal parsing and interpret 1 as a
On Tue, Oct 29, 2013 at 1:13 PM, Lopez, Dan wrote:
> grep("^([a-z]+) +\1 +[a-z]+ [0-9]",lines)
Your expression has a typo:
R> grep("^([a-z]+) +\\1 +[a-z]+ [0-9]",lines)
[1] 2
--
Sarah Goslee
http://www.functionaldiversity.org
__
R-help@r-project.or
Hi,
So I just took an intro to R programming class and one of the lectures was on
Regular Expressions. I've been playing around with various R functions that use
Regular Expressions.
But this has me stumped. This was part of a quiz and I got it right through
understanding the syntax. But when I
"6,13"
"6,13" "6,13"
>
On Tue, Jul 9, 2013 at 8:05 AM, arun wrote:
> Hi,
> May be this helps:
>
> gsub(".*\\w+\\s+(.*)\\s+.*","\\1",test)
> #[1] "9,36" "9,36" "9,66" "9,66" &quo
Hi,
May be this helps:
gsub(".*\\w+\\s+(.*)\\s+.*","\\1",test)
#[1] "9,36" "9,36" "9,66" "9,66" "9,66" "10,04" "10,04" "10,04" "6,13"
#[10] "6,13" "6,13"
On Jul 9, 2013, at 12:19 , PIKAL Petr wrote:
> Thanks, it works to some extent.
>
> The test comes from some file which is not filled propperly. If I use your
> suggestion I get correct values for those 2 digit numbers before "," but I
> get some other values which do not have space before nu
"9,66" "9,66" "9,66" "10,04""10,04""10,04"
[19] "6,13" "6,13" "6,13"
>
Basically I would like to get one or two digits before comma and two digits
after comma.
Thanks a
On Tue, Jul 09, 2013 at 09:45:55AM +, PIKAL Petr wrote:
> Dear experts in regexpr.
>
> I have this
>
> dput(test[500:510])
> c("pH 9,36 2", "pH 9,36 3", "pH 9,66 1", "pH 9,66 2", "pH 9,66 3",
> "pH 10,04 1", "pH 10,04 2", "pH 10,04 3", "RGLP 144006 pH 6,13 1",
> "RGLP 144006 pH 6,13 2", "RG
On Jul 9, 2013, at 11:45 , PIKAL Petr wrote:
> Dear experts in regexpr.
>
> I have this
>
> dput(test[500:510])
> c("pH 9,36 2", "pH 9,36 3", "pH 9,66 1", "pH 9,66 2", "pH 9,66 3",
> "pH 10,04 1", "pH 10,04 2", "pH 10,04 3", "RGLP 144006 pH 6,13 1",
> "RGLP 144006 pH 6,13 2", "RGLP 144006 pH
Dear experts in regexpr.
I have this
dput(test[500:510])
c("pH 9,36 2", "pH 9,36 3", "pH 9,66 1", "pH 9,66 2", "pH 9,66 3",
"pH 10,04 1", "pH 10,04 2", "pH 10,04 3", "RGLP 144006 pH 6,13 1",
"RGLP 144006 pH 6,13 2", "RGLP 144006 pH 6,13 3")
and I want something like this
gsub("^.*([[:digit:]]
HI,
vec1<-"'asd'f"
vec2<-'"asd"f'
gsub("[\"]","",vec2)
#[1] "asdf"
gsub("[']","",vec1)
#[1] "asdf"
A.K.
- Original Message -----
From: Christofer Bogaso
To: r-help
, TIBCO Software
wdunlap tibco.com
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On
> Behalf
> Of Christofer Bogaso
> Sent: Tuesday, January 15, 2013 1:39 PM
> To: r-help
> Subject: [R] Regular expression
>
> Hell
3 2012
2 07 3 2001
3 01 1 2002
A.K.
- Original Message -----
From: Fred G
To: r-help@r-project.org
Cc:
Sent: Tuesday, July 24, 2012 1:36 PM
Subject: [R] Regular Expression
Hi--
I have three columns in an input file:
MONTH QUARTER YEAR
2012-07 2012-3 2012
2001-
Thank you! :)
On Tue, Jul 24, 2012 at 1:42 PM, Sarah Goslee wrote:
> To delete everything from the beginning of the string to and including
> the hyphen, use
> sub("^.*-", "", tmp)
>
> Sarah
>
> On Tue, Jul 24, 2012 at 1:36 PM, Fred G wrote:
> > Hi--
> >
> > I have three columns in an input file
On Tue, Jul 24, 2012 at 1:36 PM, Fred G wrote:
> Hi--
>
> I have three columns in an input file:
> MONTH QUARTER YEAR
> 2012-07 2012-32012
> 2001-07 2001-32001
> 2002-01 2002-12002
>
> I want to make output like so:
> MONTH QUARTER YEAR
> 07 3
Station, TX 77843-4352
> -Original Message-
> From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-
> project.org] On Behalf Of Fred G
> Sent: Tuesday, July 24, 2012 12:36 PM
> To: r-help@r-project.org
> Subject: [R] Regular Expression
>
> Hi--
>
> I h
Hello,
I believe the following will do it.
d <- read.table(text="
MONTH QUARTER YEAR
2012-07 2012-32012
2001-07 2001-32001
2002-01 2002-12002
", header=TRUE)
search <- "^.*-([[:digit:]]+)$"
sapply(d, function(x) as.integer(sub(search, "\\1", x)))
Hope this he
Is this what you want:
> x <- read.table(text = "MONTH QUARTER YEAR
+ 2012-07 2012-32012
+ 2001-07 2001-32001
+ 2002-01 2002-12002", header = TRUE, as.is = TRUE)
> x
MONTH QUARTER YEAR
1 2012-07 2012-3 2012
2 2001-07 2001-3 2001
3 2002-01 2002-1 2002
> x$MON
To delete everything from the beginning of the string to and including
the hyphen, use
sub("^.*-", "", tmp)
Sarah
On Tue, Jul 24, 2012 at 1:36 PM, Fred G wrote:
> Hi--
>
> I have three columns in an input file:
> MONTH QUARTER YEAR
> 2012-07 2012-32012
> 2001-07 2001-32001
Hi Fred,
I'm no regex ninja (and I imagine one will be along shortly to solve
your problem) but in your case does it simply suffice to drop the
first 5 characters? That might be an easier sub() to write.
Best,
Michael
On Tue, Jul 24, 2012 at 12:36 PM, Fred G wrote:
> Hi--
>
> I have three colum
Hi,
one problem, many solutions, only one of which uses regular expression but work
equally well.
dat1<-read.table(text="
MONTH QUARTER YEAR
2012-07 2012-32012
2001-07 2001-32001
2002-01 2002-12002
",sep="",as.is = TRUE, header=TRUE)
# using substr:
substr(dat1
If you want that output.
substr()
Can help in your task too.
I can not help with regular expression, I will learn too.
> Date: Tue, 24 Jul 2012 13:36:25 -0400
> From: bayespoker...@gmail.com
> To: r-help@r-project.org
> Subject: [R] Regular Expression
>
> Hi--
>
&
Hi--
I have three columns in an input file:
MONTH QUARTER YEAR
2012-07 2012-32012
2001-07 2001-32001
2002-01 2002-12002
I want to make output like so:
MONTH QUARTER YEAR
07 32012
07 32001
01 1
On Mon, Jun 4, 2012 at 4:48 PM, Erin Hodgess wrote:
> Dear R People:
>
> Are there any courses which describe how to use regular expressions in
> R, please? Or any books, please?
>
> I know a little bit (very little) but would like to know more.
>
You might want to go through the regular express
On Jun 4, 2012, at 3:48 PM, Erin Hodgess wrote:
> Dear R People:
>
> Are there any courses which describe how to use regular expressions in
> R, please? Or any books, please?
>
> I know a little bit (very little) but would like to know more.
>
> Thanks,
> Erin
Hi Erin,
The two places that
Dear R People:
Are there any courses which describe how to use regular expressions in
R, please? Or any books, please?
I know a little bit (very little) but would like to know more.
Thanks,
Erin
--
Erin Hodgess
Associate Professor
Department of Computer and Mathematical Sciences
University o
gsub('.+; (.+);.+','\\1',x)
or if you just want the value out:
gsub('.+; Surv\\(months\\): ([0-9]+);.+','\\1',x)
You can also look at strsplit:
> strsplit(x,';')
[[1]]
[1] "99-625: Cell type: S"" Surv(months): 21" "
STATUS(0=alive, 1=dead): 1"
> lapply(strsplit(x,';'),'[',2)
[
On Wed, Feb 29, 2012 at 2:24 PM, Fred G wrote:
> Computer Friends,
>
> with the following example lines:
>
> [107] "98-610: Cell type: S; Surv(months): 6; STATUS(0=alive, 1=dead): 1"
>
> [108] "99-625: Cell type: S; Surv(months): 21; STATUS(0=alive, 1=dead): 1"
>
> i want to be able to isolate the
On Feb 29, 2012, at 2:24 PM, Fred G wrote:
Computer Friends,
with the following example lines:
Modified to be correct R code. Please emulate my example in the future.
inp <-c( "98-610: Cell type: S; Surv(months): 6; STATUS(0=alive,
1=dead): 1",
"99-625: Cell type: S; Surv(months): 21; ST
Computer Friends,
with the following example lines:
[107] "98-610: Cell type: S; Surv(months): 6; STATUS(0=alive, 1=dead): 1"
[108] "99-625: Cell type: S; Surv(months): 21; STATUS(0=alive, 1=dead): 1"
i want to be able to isolate the number of months of survival for each row.
is there a regula
On 14.11.2011 11:27, Petr PIKAL wrote:
Hi
Thank you. It is a pure magic, something taught in Unseen University.
this is what I got as a help for selecting only letters from set of
character vector.
vzor
[1] "61A" "62C/27" "65A/27" "66C/29" "69A/29" "70C/31"
"73A/31"
[8] "74C/33
Hi
Thank you. It is a pure magic, something taught in Unseen University.
this is what I got as a help for selecting only letters from set of
character vector.
> vzor
[1] "61A" "62C/27" "65A/27" "66C/29" "69A/29" "70C/31"
"73A/31"
[8] "74C/33" "77A/33" "81A/35" "82C/37" "85A/37"
Does
library( stringr )
str_extract( mena, "m5[0-9]" )
achieve what you are looking for?
Rgds,
Rainer
On Monday 14 November 2011 10:22:09 Petr PIKAL wrote:
> Hi
>
> > On 11/14/2011 07:45 PM, Petr PIKAL wrote:
> > > Dear all
> > >
> > > I am again (as usual) lost in regular expression use for
On 14.11.2011 10:22, Petr PIKAL wrote:
Hi
On 11/14/2011 07:45 PM, Petr PIKAL wrote:
Dear all
I am again (as usual) lost in regular expression use for selection.
Here
are my data:
dput(mena)
c("138516_10g_50ml_50c_250utes1_m53.00-_s1.imp",
"138516_10g_50ml_50c_250utes1_m54.00_s1.imp",
"
Hi
> On 11/14/2011 07:45 PM, Petr PIKAL wrote:
> > Dear all
> >
> > I am again (as usual) lost in regular expression use for selection.
Here
> > are my data:
> >
> >> dput(mena)
> > c("138516_10g_50ml_50c_250utes1_m53.00-_s1.imp",
> > "138516_10g_50ml_50c_250utes1_m54.00_s1.imp",
> > "138516_10g_
Hi
>
> Hi,
>
> Try grepl instead of sub,
>
> mena[grepl("m5.", mena)]
It does not select those "m5?" strings from those character vectors. I
need as an output a vector
m53, m54, m55, m56, m57, m58, m59
Regards
Petr
>
> HTH,
>
> baptiste
>
> On 14 November 2011 21:45, Petr PIKAL wrote:
On 11/14/2011 07:45 PM, Petr PIKAL wrote:
Dear all
I am again (as usual) lost in regular expression use for selection. Here
are my data:
dput(mena)
c("138516_10g_50ml_50c_250utes1_m53.00-_s1.imp",
"138516_10g_50ml_50c_250utes1_m54.00_s1.imp",
"138516_10g_50ml_50c_250utes1_m55.00_s1.imp",
"138
Hi,
Try grepl instead of sub,
mena[grepl("m5.", mena)]
HTH,
baptiste
On 14 November 2011 21:45, Petr PIKAL wrote:
> Dear all
>
> I am again (as usual) lost in regular expression use for selection. Here
> are my data:
>
>> dput(mena)
> c("138516_10g_50ml_50c_250utes1_m53.00-_s1.imp",
> "138516
Dear all
I am again (as usual) lost in regular expression use for selection. Here
are my data:
> dput(mena)
c("138516_10g_50ml_50c_250utes1_m53.00-_s1.imp",
"138516_10g_50ml_50c_250utes1_m54.00_s1.imp",
"138516_10g_50ml_50c_250utes1_m55.00_s1.imp",
"138516_10g_50ml_50c_250utes1_m56.00_s1.imp"
That works like a charm! Thanks so much Duncan.
On Fri, Apr 29, 2011 at 6:37 PM, Duncan Murdoch wrote:
> On 29/04/2011 9:34 PM, Miao wrote:
>
>> Thanks Duncan for clarifying this. I'm pretty a newbie to such type of
>> characters and special characters. In R's gsub() what regular
>> expression
On Fri, 29 Apr 2011, Duncan Murdoch wrote:
On 29/04/2011 7:41 PM, Miao wrote:
Can anyone help on gsub() in R? I have a string like something below, and
wanted to delete all the strings with leading backslash, including
"\xa0On",
"\023, "\xab", and many others. How should I write a regular
On 29/04/2011 9:34 PM, Miao wrote:
Thanks Duncan for clarifying this. I'm pretty a newbie to such type of
characters and special characters. In R's gsub() what regular
expressions shall I use to handle all these situations?
I don't know. This might work:
gsub("[\x01-\x1f\x7f-\xff]", "", x)
Thanks Duncan for clarifying this. I'm pretty a newbie to such type of
characters and special characters. In R's gsub() what regular expressions
shall I use to handle all these situations?
On Fri, Apr 29, 2011 at 6:07 PM, Duncan Murdoch wrote:
> On 29/04/2011 7:41 PM, Miao wrote:
>
>> Hello,
>
On 29/04/2011 7:41 PM, Miao wrote:
Hello,
Can anyone help on gsub() in R? I have a string like something below, and
wanted to delete all the strings with leading backslash, including "\xa0On",
"\023, "\xab", and many others. How should I write a regular expression
pattern in gsub()? I don't
Hello,
Can anyone help on gsub() in R? I have a string like something below, and
wanted to delete all the strings with leading backslash, including "\xa0On",
"\023, "\xab", and many others. How should I write a regular expression
pattern in gsub()? I don't care how many characters following ba
2011/4/25 Gonçalo Ferraz :
> Hi, I have a string
>
> "InTrouble"
>
> and want to extract, say, the first two characters: "In"
> or the last three: "blee"
> or the 3rd, 4th, and 5th: "Trou"
>
> Is there an easy way of doing this quickly with regular expressions in gsub,
> grep or similar?
>
strapp
On Apr 25, 2011, at 6:17 AM, Gonçalo Ferraz wrote:
Hi, I have a string
"InTrouble"
and want to extract, say, the first two characters: "In"
or the last three: "blee"
or the 3rd, 4th, and 5th: "Trou"
Is there an easy way of doing this quickly with regular expressions
in gsub, grep or simila
On 04/25/2011 08:17 PM, Gonçalo Ferraz wrote:
Hi, I have a string
"InTrouble"
and want to extract, say, the first two characters: "In"
or the last three: "blee"
or the 3rd, 4th, and 5th: "Trou"
Is there an easy way of doing this quickly with regular expressions in gsub,
grep or similar?
Hi
will this do it:
> x <- "InTrouble"
> sub("^(..).*", "\\1", x) # first two
[1] "In"
> sub(".*(...)$", "\\1", x) # last three
[1] "ble"
> sub("^..(...).*", "\\1", x) # 3rd,4th,5th char
[1] "Tro"
>
2011/4/25 Gonçalo Ferraz :
> Hi, I have a string
>
> "InTrouble"
>
> and want to extract, say, t
Hi, I have a string
"InTrouble"
and want to extract, say, the first two characters: "In"
or the last three: "blee"
or the 3rd, 4th, and 5th: "Trou"
Is there an easy way of doing this quickly with regular expressions in gsub,
grep or similar?
Thank you for any help.
Gonçalo
__
Hi Erin,
Please read ?grep. It is clearly not the function you want (neither
is strsplit() either really). This does what you want and you can
modify for upper/lower case if you need it. Also note that regular
expressions exist separate from R, so while ":" may have seemed
natural to select a r
On Mon, Apr 11, 2011 at 10:49 PM, Erin Hodgess wrote:
> Dear R People:
>
> I have a data frame with the following column names:
>
>> names(funky)
> [1] "UHD.1" "UHD.2" "UHD.3" "UHD.4" "L..W..1" "L..W..2" "L..W..3"
> [8] "L..W..4" "B..W..1" "B..W..2" "B..W..3" "B..W..4" "W..B..1" "W..B..2
Dear R People:
I have a data frame with the following column names:
> names(funky)
[1] "UHD.1" "UHD.2" "UHD.3" "UHD.4" "L..W..1" "L..W..2" "L..W..3"
[8] "L..W..4" "B..W..1" "B..W..2" "B..W..3" "B..W..4" "W..B..1" "W..B..2"
[15] "W..B..3" "W..B..4" "B..G..1" "B..G..2" "B..G..3" "B..G..4"
gt; Great. thank you Bernd! Learned a new thing here.
>
> John
>
>
>
>
>
> From: Bernd Weiss
>
> Cc: r-help@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 ch
Great. thank you Bernd! Learned a new thing here.
John
From: Bernd Weiss
Cc: r-help@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
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 inc
t including "arg" before ".", but at the same time,
does include ".symptom".
Any other suggestions would be appreciated
John
From: Peter Langfelder
Cc: Bernd Weiss ; r-help@r-project.org
Sent: Thu, March 31, 2011 5:55:26 PM
On Thu, Mar 31, 2011 at 5:49 PM, array chip wrote:
> Thanks Bernd! I tried your approach with my real example, sometimes it worked,
> sometimes it didn't. For example
>
> grep('[^(arg)]\\.symptom',"stomach.symptom",value=T)
> [1] "stomach.symptom"
>
> grep('[^(arg)]\\.symptom',"liver.symptom",valu
)
character(0)
I think both examples should return the text, but the 2nd example didn't.
What was wrong here?
Thanks
John
From: Bernd Weiss
Sent: Thu, March 31, 2011 5:32:25 PM
Subject: Re: [R] regular expression
Am 31.03.2011 19:31, schrieb array chip:
&
Am 31.03.2011 19:31, schrieb array chip:
Hi, I am stuck on this: how to specify a match pattern that means not
to include "abc"?
I tried:
grep("^(abc)", "hello", value=T) should return "hello".
> grep("[^(abc)]", "hello", value=T)
[1] "hello"
HTH,
Bernd
___
Hi, I am stuck on this: how to specify a match pattern that means not to
include
"abc"?
I tried:
grep("^(abc)", "hello", value=T)
should return "hello".
while
grep("^(abc)", "hello abcd foo", value=T)
should return character(0).
But both returned character(0).
Thanks
John
[[alte
On Mon, Feb 14, 2011 at 4:13 AM, Deb Midya wrote:
> Hi R users,
>
> Thanks in advance.
>
> I am using R-2.12.1 on Windows XP.
>
> I am looking for some good literature on Regular Expression. May I request
> you to assist me please.
There are regular expression links on the gsubfn home page:
http
Hi R users,
Thanks in advance.
I am using R-2.12.1 on Windows XP.
I am looking for some good literature on Regular Expression. May I request you
to assist me please.
Once again, thank you very much for the time you have given.
Regards,
Deb
[[alternative HTML version d
On Wed, Oct 13, 2010 at 2:16 PM, Bart Joosen wrote:
>
> Hi,
>
> this should be an easy one, but I can't figure it out.
> I have a vector of tests, with their units between brackets (if they have
> units).
> eg tests <- c("pH", "Assay (%)", "Impurity A(%)", "content (mg/ml)")
>
strapply in gsubfn
1 - 100 of 166 matches
Mail list logo