Displaying 20 results from an estimated 5000 matches similar to: "regex question"
2010 Jul 08
2
strsplit("dia ma", "\\b") splits characterwise
\b is word boundary.
But, unexpectedly, strsplit("dia ma", "\\b") splits character by character.
> strsplit("dia ma", "\\b")
[[1]]
[1] "d" "i" "a" " " "m" "a"
> strsplit("dia ma", "\\b", perl=TRUE)
[[1]]
[1] "d" "i" "a" " "
2010 Sep 27
7
Regular expressions: offsets of groups
Dear list!
> gregexpr("a+(b+)", "abcdaabbc")
[[1]]
[1] 1 5
attr(,"match.length")
[1] 2 4
What I want is the offsets of the matches for the group (b+), i.e. 2
and 7, not the offsets of the complete matches. Is there a way in R
to get that?
I know about gsubgn and strapply, but they only give me the strings
matched by groups not their offsets.
I could write
2006 Nov 07
1
Gregexpr - extract results with lapply
Gregexpr - extract results with lapply
Hello,
I need to extract sequences of three upper case letters in a string. In
other words, in this string:
str <-c("ABC", "this WOUld be gOOD")
The result I'm looking for is ABC WOU OOD.
With gregexpr, I can get the position and length of the sequences
gregexpr('[A-Z]{3}',str,perl=TRUE)
[[1]]
[1] 1
2008 Jul 03
1
how to capture matching words in a string ?
I need to capture matching words in a string, any ideas ?
I tried using gregexpr, but it was no help. In this example, I need to capture ID23423424 and ID324234325
> s <- "sID23423424 apple pID324234325 orange"> gregexpr("ID[0-9]+", s)[[1]][1] 2 20attr(,"match.length")[1] 10 11
_________________________________________________________________
2010 Feb 08
2
the hat ^ in regular expression
Un texte encapsul? et encod? dans un jeu de caract?res inconnu a ?t? nettoy?...
Nom : non disponible
URL : <https://stat.ethz.ch/pipermail/r-help/attachments/20100208/52a6d080/attachment.pl>
2008 Nov 13
1
replacing Na's in a vector with the preceding integer element
Hi,
I have a vector where an integer is followed by a randomly varying number of NA elements. I want to replace the NA's with the preceding integer. Let me explain with a simple?example :
avec<- c(1,NA,NA,5,NA,3,4,NA,NA,NA,NA,9,NA,0,NA,NA)
I want to get the following vector from a :
bvec<-c(1,1,1,5,5,3,4,4,4,4,4,9,9,0,0,0)
How can I do this with R? Will appreciate all the help that I
2008 Aug 10
2
Basic data structures
I'm new to R and very excited about its possibilities. But I'm
struggling with some very simple things, probably because I haven't
found the correct documentation. Here's a simple example which
illustrates several of my problems.
Suppose I want to have a regexp match against a string, and return all
the matching substrings in a vector of strings.
regexp <-
2010 Aug 20
4
Regex exercise
For regular expression afficianados, I'd like a cleverer solution to
the following problem (my solution works just fine for my needs; I'm
just trying to improve my regex skills):
Given the string (entered, say, at a readline prompt):
"1 2 -5, 3- 6 4 8 5-7 10" ## only integers will be entered
parse it to produce the numeric vector:
c(1, 2, 3, 4, 5, 3, 4, 5, 6, 8, 5, 6,
2006 May 06
2
regular expression change in R version 2.3.0?
The interpretation of regular expressions with repetition
quantifiers in the 'gregexpr' function seems to have changed
between R Version 2.2.0 and 2.3.0. The 'gsub' function, however,
gives the same results in R Versions 2.2.0 and 2.3.0. Below is
an example that demonstrates the version differences of the
'gregexpr' function. I am not sure whether this new behavior
is
2009 Aug 26
2
find numbers in a line with letters
hi,
is there an easy way to extract numbers from a string?
for example I have;
"this Item costs 3.32 Dollars"
is there an easy way to extract the 3.32 as a number?
thanks!
2011 Aug 17
2
question regarding gregexpr and read.table
Hi,
I have a silly question regarding the usage of two commands: read.table and
gregexpr:
For read.table, if I read a matrix and set header = T, I found that all the
dash ("-") becomes dots (".")
A = read.table("Matrix.txt", sep = "\t", header = F)
A[1,1]
# "A-B-C-D".
A = read.table("Matrix.txt", sep = "\t", header = T)
2009 Feb 25
1
Using gregexpr with multiple search elements
Dear list,
I am trying to use gregexpr to see if entries in a dataframe have
either of two possible values for a string.
here's an example
text<-c("fat", "rat", "cat", "dog", "log", "fish")
If I just wanted to find if any one of the elements in text match the
pattern "at" I would do
gregexpr("\\at", text)
2007 May 22
1
regexp bug in very recent r-devel
completion is semi-broken in today's r-devel, and the reason seems to
be some regular expression changes:
> sessionInfo()
R version 2.6.0 Under development (unstable) (2007-05-22 r41673)
i686-pc-linux-gnu
locale:
[...]
attached base packages:
[1] "stats" "graphics" "grDevices" "utils" "datasets" "methods"
[7]
2019 Feb 19
1
patch for gregexpr(perl=TRUE)
Hi all,
Several people have noticed that gregexpr is very slow for large subject
strings when perl=TRUE is specified.
-
https://stackoverflow.com/questions/31216299/r-faster-gregexpr-for-very-large-strings
-
http://r.789695.n4.nabble.com/strsplit-perl-TRUE-gregexpr-perl-TRUE-very-slow-for-long-strings-td4727902.html
- https://stat.ethz.ch/pipermail/r-help/2008-October/178451.html
I figured out
2007 Aug 02
4
Finding multiple characters in the same string
Hi
I have this problem where I need to find if there is any numbers in a
string, this is no problem if theres only one number per string. I would
then simply use the regexpr() funtion togheter with the substring function
to extract the number. But regexpr only picks one number per string either
from the beginning or the end, but not multiple. Can this be done? And how
for example
My string <-
2007 Oct 10
4
gregexpr (PR#9965)
Full_Name: Peter Dolan
Version: 2.5.1
OS: Windows
Submission from: (NULL) (128.193.227.43)
gregexpr does not find all matching substrings if the substrings overlap:
> gregexpr("abab","ababab")
[[1]]
[1] 1
attr(,"match.length")
[1] 4
It does work correctly in Version 2.3.1 under linux.
2010 Feb 01
5
regular expression submatch?
What is the simplest way to extract a matched subexpression?
Eg. in perl you can do
"hello world" =~ m/hello (.*)/
which would return 1(true) and set $1 to the matched subexpression "world".
--
View this message in context: http://n4.nabble.com/regular-expression-submatch-tp1459146p1459146.html
Sent from the R help mailing list archive at Nabble.com.
2009 Aug 17
1
regex problems with the escape character
Hi R-users and R-experts,
I am having a hard time in figuring out how to tackle regex questions where the "backslash" character is an integral part of the string. Let me explain how I?came across?this problem :
I wanted to clearly see all the components in the windows environmental path variable. This is a long string.?For easy readability, I wanted to split up this string so that each
2008 May 07
6
help with updating to R2.7
Hi,
From R 2.6, I would like to update to R2.7. I would like to have some tips on the recommended method of installing the latest versions of an entire list of packages in R2.7 - i.e. all the packages that I have presently installed in R2.6.
I am hoping that there is an easier method than fetching the packages individually as I did, to begin with, for R2.6.
Additionally, I would like to install
2006 Jan 10
1
VMauthenticate always asks for mailbox
I've been trying to use the VMAuthenticate function in 1.2+. This
function is supposed to "behave[s] the same way as the Authenticate
application, but the passwords are taken from voicemail.conf."
The problem is that it always gives the "comedian mail" prompt and
requests the mailbox number, even though I provide the mailbox
number already.
The upshot is that