Displaying 20 results from an estimated 4000 matches similar to: "pattern search"
2011 Oct 05
1
fgrep with caret (^) meta-character in system() call
Hi there,
I would like to use my linux system's fgrep to search for a text pattern
in a file. Calling system with
system("fgrep \"SearchPattern\" /path/to/the/textFile.txt")
works in general, but I need to search for the search pattern at the
beginning of the line.
The corresponding shell command
fgrep "^SearchPattern" /path/to/the/textFile.txt
2015 Jul 16
4
doveadm import - strange warning
I'm using the doveadm import command to extract mails from my backup:
% doveadm import -u restore at backup.invalid mdbox:/home/copymail/mdbox "" \
mailbox INBOX header Delivered-To backup+$SEARCHPATTERN at backup.invalid
This works like a charm, I'm getting all the mails, and I can access
the newly generated mailbox.
But when executing the command I'm getting an
2013 Jan 07
3
pattern matching
Hi,
I have a simple question. Suppose I have a string "x$Expensive". I want
to find the position of the $ in this string; i.e., I want a function
that returns 2. I tried grep, regexpr, etc with no luck, unless I'm
just using them incorrectly. Any suggestions?
Thanks,
Walt
________________________
Walter R. Paczkowski, Ph.D.
Data Analytics Corp.
44 Hamilton Lane
Plainsboro,
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.
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
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>
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)
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
2013 Mar 20
2
Pattern match
Hello again, in the help page of grep() function, it is written that
pattern:
character string containing a regular expression (or character string
for fixed = TRUE) to be matched in the given character vector. Coerced
by as.character to a character string if possible. If a character
vector of length 2 or more is supplied, the first element is used with
a warning. Missing values are allowed
2008 Dec 12
4
gregexpr - match overlap mishandled (PR#13391)
Full_Name: Reid Thompson
Version: 2.8.0 RC (2008-10-12 r46696)
OS: darwin9.5.0
Submission from: (NULL) (129.98.107.177)
the gregexpr() function does NOT return a complete list of global matches as it
should. this occurs when a pattern matches two overlapping portions of a
string, only the first match is returned.
the following function call demonstrates this error (although this is not how I
2008 Dec 12
4
gregexpr - match overlap mishandled (PR#13391)
Full_Name: Reid Thompson
Version: 2.8.0 RC (2008-10-12 r46696)
OS: darwin9.5.0
Submission from: (NULL) (129.98.107.177)
the gregexpr() function does NOT return a complete list of global matches as it
should. this occurs when a pattern matches two overlapping portions of a
string, only the first match is returned.
the following function call demonstrates this error (although this is not how I
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)
2009 Aug 04
4
regex question
Hi,
I am getting stuck over an apparently simple problem in the use of regular expressions :
To collect together the first letters of the words from the Perl motto, ?There is more than one way to do it? in the following form ? TIMTOWTDI.
I tried the following code :
?
##### A regex problem with the Perl motto
astr<-"There is more than one way to do it"
b1<-grep("\\<",
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
2005 Nov 03
3
Search within a file
Hi,
I am looking for a way to search a file for position of some expression,
from within R. My current code:
sha1Pos = gregexpr("<sha1>", readChar(filename,
file.info(filename)$size))[[1]]
Works fine for small files, but text files I will be working with might get
up to Gb range, so I was trying to accomplish the same without loading the
whole file into R.
I realize this is
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 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]
2012 Nov 02
2
backreferences in gregexpr
Hi Folks,
I'm trying to extract just the backreferences from a regex.
> temp = "abcd1234abcd1234"
> regmatches(temp, gregexpr("(?:abcd)(1234)", temp))
[[1]]
[1] "abcd1234" "abcd1234"
What I would like is:
[1] "1234" "1234"
Note: I know I can just match 1234 here, but the actual example is
complicated enough that I have to
2012 Mar 30
1
How to use access results of gregexpr in data frames
Hello,
I'm trying to figure out how to find the index of the second occurrence of "/" in a string (which happens to represent a date) within a data frame column.
I've used the following code successfully to find the first instance of "/".
dframe <- data.frame(date=c("5/14/2011", "4/7/2011"))
dframe$x1 <- regexpr("/", dframe[, 1])