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
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
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 %>%
>
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
--
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
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
"(^| +)([^/ ]*/?){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("(^| *)([^/
> 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
> 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.
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
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
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
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
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
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,
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)
res -
On Wed, Jan 14, 2015 at 10:03 AM, MacQueen, Don macque...@llnl.gov 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,
: Wednesday, January 14, 2015 at 8:47 AM
To: dh m macque...@llnl.govmailto:macque...@llnl.gov
Cc: Mark Leeds marklee...@gmail.commailto:marklee...@gmail.com,
r-help-stat.math.ethz.ch
r-h...@stat.math.ethz.chmailto:r-h...@stat.math.ethz.ch
Subject: Re: [R] regular expression question
On Wed, Jan 14, 2015
Hi Mark,
Mark Leeds marklee...@gmail.com 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
No HTML please. it makes me itchy! grin/
s - c(lngimbintrhofixed,lngimbnointnorhofixed,test)
sub('(no)?rhofixed$','',s)
[1] lngimbint lngimbnoint test
On Mon, Jan 12, 2015 at 1:37 PM, Mark Leeds marklee...@gmail.com wrote:
Hi All: I have a regular expression problem. If a character
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 know
: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 ':', 's', 'p', 'a', 'c', and
'e' (the second colon is superfluous). I.e
...@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
pattern, as in
grep(value=TRUE, (^|//|[[:space:]]+)AARSD1
)
grepl('^AARSD1//$|^AARSD1 //$|^//AARSD1$|^AARSD1$', test)
[1] FALSE FALSE TRUE TRUE TRUE TRUE
--
David.
Thanks,
Lin
From: dulca...@bigpond.com
To: bac...@hotmail.com; r-help@r-project.org
Subject: RE: [R] regular expression help
Date: Fri
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
pattern, as in
grep(value=TRUE
: RE: [R] regular expression help
Date: Fri, 27 Jun 2014 10:59:29 +1000
Hi
You only have a vector of length 5 and I am not quite sure of the string you
are testing
so try this
grep('[/]*\\AARSD1\\[/]*',test)
Duncan
Duncan Mackay
Department of Agronomy and Soil Science
University of New
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.
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
//','//AARSD1','AARSD1'
Thanks,
Lin
From: dulca...@bigpond.com
To: bac...@hotmail.com; r-help@r-project.org
Subject: RE: [R] regular expression help
Date: Fri, 27 Jun 2014 10:59:29 +1000
Hi
You only have a vector of length 5 and I am not quite sure
From: dulca...@bigpond.com
To: bac...@hotmail.com; r-help@r-project.org
Subject: RE: [R] regular expression help
Date: Fri, 27 Jun 2014 10:59:29 +1000
Hi
You only have a vector of length 5 and I am not quite sure of the string you
are testing
so try
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
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 `[^0-9]` ?
-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 [^0-9] in R regular
expression?
gregexpr(pattern=[^0-9],+12345ty)
[[1]]
[1] 1 7 8
attr
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
On Tue, Oct 29, 2013 at 1:13 PM, Lopez, Dan lopez...@llnl.gov 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
__
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
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 Expression returning unexpected results
Hi,
So I
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 RAM before
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:]],[[:digit:]]*).*$,
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 6,13 3)
and I want
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, RGLP 144006 pH 6,13 3)
and
before comma and two digits
after comma.
Thanks anyway
Petr
-Original Message-
From: peter dalgaard [mailto:pda...@gmail.com]
Sent: Tuesday, July 09, 2013 11:59 AM
To: PIKAL Petr
Cc: r-help
Subject: Re: [R] regular expression strikes again
On Jul 9, 2013, at 11:45 , PIKAL Petr
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 numbers.
: [R] regular expression strikes again
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
Petr petr.pi...@precheza.cz
To: r-help r-help@r-project.org
Cc:
Sent: Tuesday, July 9, 2013 5:45 AM
Subject: [R] regular expression strikes again
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
To: r-help
Subject: [R] Regular expression
Hello again,
I am having a problem on Regular expression. Let say I have following code:
gsub([',], , 'asd'f)
[1] asdf
This is perfect. However I am having problem if I include (i.e. the
double quote) in the first argument as the pattern
HI,
vec1-'asd'f
vec2-'asdf'
gsub([\],,vec2)
#[1] asdf
gsub(['],,vec1)
#[1] asdf
A.K.
- Original Message -
From: Christofer Bogaso bogaso.christo...@gmail.com
To: r-help r-help@r-project.org
Cc:
Sent: Tuesday, January 15, 2013 4:38 PM
Subject: [R] Regular expression
Hello again
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
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--
I have three columns
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:
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 bayespoker...@gmail.com wrote:
Hi--
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 bayespoker...@gmail.com wrote:
Hi--
I have three columns in an input file:
MONTH QUARTER YEAR
2012-07 2012-32012
2001-07
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$MONTH -
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 helps,
-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 have three columns in an input file:
MONTH QUARTER YEAR
2012-07 2012-32012
2001-07 2001-32001
2002-01 2002-1
On Tue, Jul 24, 2012 at 1:36 PM, Fred G bayespoker...@gmail.com 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
Thank you! :)
On Tue, Jul 24, 2012 at 1:42 PM, Sarah Goslee sarah.gos...@gmail.comwrote:
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 bayespoker...@gmail.com wrote:
Hi--
I have
-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-07 2001-3 2001
2002-01 2002-1 2002
I want to make output like so:
MONTH QUARTER YEAR
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
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 I
On Mon, Jun 4, 2012 at 4:48 PM, Erin Hodgess erinm.hodg...@gmail.com 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
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 regular
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;
On Wed, Feb 29, 2012 at 2:24 PM, Fred G bayespoker...@gmail.com 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
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)
[[1]]
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,
Hi,
Try grepl instead of sub,
mena[grepl(m5., mena)]
HTH,
baptiste
On 14 November 2011 21:45, Petr PIKAL petr.pi...@precheza.cz wrote:
Dear all
I am again (as usual) lost in regular expression use for selection. Here
are my data:
dput(mena)
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,
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 petr.pi...@precheza.cz
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,
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,
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
selection.
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 86C/39
89A/39
[15]
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 77A/33
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
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 care
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 murdoch.dun...@gmail.comwrote:
On 29/04/2011 7:41 PM,
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)
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
That works like a charm! Thanks so much Duncan.
On Fri, Apr 29, 2011 at 6:37 PM, Duncan Murdoch murdoch.dun...@gmail.comwrote:
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
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
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 gferra...@gmail.com:
Hi, I have a string
InTrouble
and want to extract, say, the first two
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
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 similar?
2011/4/25 Gonçalo Ferraz gferra...@gmail.com:
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?
On Mon, Apr 11, 2011 at 10:49 PM, Erin Hodgess erinm.hodg...@gmail.com 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
[15]
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
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
I would like to extract the letters
Great. thank you Bernd! Learned a new thing here.
John
From: Bernd Weiss bernd.we...@uni-koeln.de
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
From: Bernd Weiss bernd.we...@uni-koeln.de
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 I wanted. I want not including
'arg' before
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
[[alternative
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
__
, but the 2nd example didn't.
What was wrong here?
Thanks
John
From: Bernd Weiss bernd.we...@uni-koeln.de
Sent: Thu, March 31, 2011 5:32:25 PM
Subject: Re: [R] regular expression
Am 31.03.2011 19:31, schrieb array chip:
Hi, I am stuck on this: how to specify
On Thu, Mar 31, 2011 at 5:49 PM, array chip arrayprof...@yahoo.com 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
,
does include .symptom.
Any other suggestions would be appreciated
John
From: Peter Langfelder peter.langfel...@gmail.com
Cc: Bernd Weiss bernd.we...@uni-koeln.de; r-help@r-project.org
Sent: Thu, March 31, 2011 5:55:26 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
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
On Mon, Feb 14, 2011 at 4:13 AM, Deb Midya debmi...@yahoo.com 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
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))
Now I would like to hava a function where I use a test as input, and which
returns the units
1 - 100 of 158 matches
Mail list logo