Displaying 20 results from an estimated 10000 matches similar to: "Parsing regular expressions differently - feature request"
2013 Feb 05
2
R Regular Expressions - Metacharacters
I thought that I can use metacharacters such as \w to match word characters
with one backslash. But for some reason, I need to include two backslashes.
> grepl(pattern='\w', x="what")
Error: '\w' is an unrecognized escape in character string starting "\w"
> grepl(pattern='\\w', x="what")
[1] TRUE
I can't find the reason for this
2009 May 13
4
matching period with perl regular expression
Hello,
I have several strings where I am trying to eliminate the period and
everything after the period, using a regular expression. However, I am
having trouble getting this to work.
> x = "wa.w"
> gsub(x, "\..*", "", perl=TRUE)
[1] ""
Warning messages:
1: '\.' is an unrecognized escape in a character string
2: unrecognized escape removed
2014 Apr 24
1
The regular expressions in compareVersion()
Hi,
I guess the backslash should not be used as the separator for
strsplit() in compareVersion(), because the period in [.] is no longer
a metacharacter (no need to "escape" it using a backslash):
https://github.com/wch/r-source/blob/trunk/src/library/utils/R/packages.R#L866-L867
> compareVersion
function (a, b)
{
....
a <- as.integer(strsplit(a, "[\\.-]")[[1L]])
2005 May 23
1
Backslash
Why sometimes one has to put a double
backslash in regular expressions, but
often simple backslashes work too?
Is only a \ required for giving a
metacharacter its usual meaning?
---------------------------------------
u=grep('\\{[\\-u]x',a,perl=T)
# equivalent to
u=grep('\{[\-u]x',a,perl=T)
# but
u=grep('\w',a,perl=T)
# is not correct and requires
2008 Aug 06
1
Matching a period in grep...
Hi folks,
Can anyone enlighten me as to why I get the following when I search for
".csv" at the end of a string?
> grep("\.csv$","Blah.csv",value=TRUE)
[1] "Blah.csv"
Warning messages:
1: '\.' is an unrecognized escape in a character string
2: unrecognized escape removed from "[\.]csv$"
R reference for regular expressions says
2012 Nov 08
3
strsplit with invalid regular expression
Hi all,
> diff_operator <- "\\("
> strsplit(cond, diff_operator)
[[1]]
[1] "andsin" "log_angle_1_4)"
> diff_operator <- "\\sin("
> strsplit(cond, diff_operator)
Error in strsplit(cond, diff_operator) :
invalid regular expression '\sin(', reason 'Missing ')''
When I am going to split with "("
2007 Jan 03
3
pb in regular expression with the character "-" (PR#9437)
Full_Name: FAN
Version: 2.4.0
OS: Windows
Submission from: (NULL) (159.50.101.9)
These are expected:
> grep("[\-|c]", c("a-a","b"))
[1] 1
> gsub("[\-|c]", "&", c("a-a","b"))
[1] "a&a" "b"
but these are strange:
> grep("[d|\-|c]", c("a-a","b"))
integer(0)
2019 Feb 25
3
pcre problems
Hi there, ubuntu 18.04.2, trying to compile R-devel 3.6.0, svn 76155.
I am having difficulty compiling R. I think I have pcre installed correctly:
OK~/Downloads/R-devel pcretest -C
PCRE version 8.41 2017-07-05
Compiled with
8-bit support
UTF-8 support
No Unicode properties support
No just-in-time compiler support
Newline sequence is LF
\R matches all Unicode newlines
Internal
2017 Jun 14
8
[WISH / PATCH] possibility to split string literals across multiple lines
Hi,
I would really like to have a way to split long string literals across
multiple lines in R.
Currently, if a string literal spans multiple lines, there is no way to
inhibit the introduction of newline characters:
> "aaa
+ bbb"
[1] "aaa\nbbb"
If a line ends with a backslash, it is just ignored:
> "aaa\
+ bbb"
[1] "aaa\nbbb"
We could use
2006 Jan 27
4
regular expressions, sub
Hi,
I am trying to use sub, regexpr on expressions like
log(D) ~ log(N)+I(log(N)^2)+log(t)
being a model specification.
The aim is to produce:
"ln D ~ ln N + ln^2 N + ln t"
The variable names N, t may change, the number of terms too.
I succeded only partially, help on regular expressions is hard to
understand for me, examples on my case are rare. The help page on R-help
2007 Feb 16
13
negate the regexp in validates_format_of
Railsters:
ActiveRecord''s validation system puts other database systems to shame.
However, the newbies might not know how to write a regexp that
excludes a match, instead of tests for it. Understand - I''m just
asking this question to help them. I have been using Regexps since
''grep'' on Xenix! But the newbies here might not know how to do this:
2006 Mar 31
2
Backslash Escaping in View
Ok, I''m hoping this won''t be a forehead slapper, but take a look at this code:
physician.name.sub(/''/, "\\''")
I''m trying to substitute a single quote with a backslash and a single
quote. This seems pretty simple right? Well, someone kick me and
tell me why it''s not :)
Here''s what I''m getting if the
2010 Apr 09
4
perhaps regular expression bug with | sign ??
Here is my interaction with R:
> sub(x='>|t|',pattern = '|t',replacement='zz')
[1] "zz>|t|"
So I say to myself "Clearly the | signs need to be escaped, so let's try
this"
> sub(x='>|t|',pattern = '\|t',replacement='zz')
[1] "zz>|t|"
Warning messages:
1: '\|' is an unrecognized escape in a
2017 Jun 14
4
[WISH / PATCH] possibility to split string literals across multiple lines
On Wed, 14 Jun 2017 06:12:09 -0500, Duncan Murdoch <murdoch.duncan at gmail.com> wrote:
> On 14/06/2017 5:58 AM, Andreas Kersting wrote:
> > Hi,
> >
> > I would really like to have a way to split long string literals across
> > multiple lines in R.
>
> I don't understand why you require the string to be a literal. Why not
> construct the long
2019 Mar 01
2
pcre problems
thanks for this guys.
I only compiled pcre myself as a last resort, because of the
./configure failure. But AFAICS apt-get reports correct
installation:
OK~/Downloads/R-devel sudo apt-get install r-base-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
r-base-dev is already the newest version (3.5.2-1cosmic).
0 upgraded, 0 newly installed, 0 to
2019 Mar 01
2
pcre problems
thanks for this guys.
I only compiled pcre myself as a last resort, because of the
./configure failure. But AFAICS apt-get reports correct
installation:
OK~/Downloads/R-devel sudo apt-get install r-base-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
r-base-dev is already the newest version (3.5.2-1cosmic).
0 upgraded, 0 newly installed, 0 to
2009 Jun 09
0
[LLVMdev] Regular Expressions
> On Tuesday 09 June 2009 04:35, Török Edwin wrote:
> > On 2009-06-09 12:27, Howard Su wrote:
> > > This change break the MSVC build since no regex by default in Windows
> > > MSVC platform.
> >
> > Perhaps we should add a regex implementation to lib/System?
>
> That's potentially a lot of work. I started looking at it and it would
> involve
2019 Mar 01
2
pcre problems
OK thanks Tomas, but I get
OK~ sudo apt-get build-dep r-base
Reading package lists... Done
E: Unable to find a source package for r-base
OK~
hankin.robin at gmail.com
On Fri, Mar 1, 2019 at 8:47 PM Tomas Kalibera <tomas.kalibera at gmail.com> wrote:
>
> On 3/1/19 7:10 AM, robin hankin wrote:
> > thanks for this guys.
> >
> > I only compiled pcre myself as a last
2019 Mar 01
2
pcre problems
OK thanks Tomas, but I get
OK~ sudo apt-get build-dep r-base
Reading package lists... Done
E: Unable to find a source package for r-base
OK~
hankin.robin at gmail.com
On Fri, Mar 1, 2019 at 8:47 PM Tomas Kalibera <tomas.kalibera at gmail.com> wrote:
>
> On 3/1/19 7:10 AM, robin hankin wrote:
> > thanks for this guys.
> >
> > I only compiled pcre myself as a last
2012 Jul 08
3
list.files() find files beginning with a .
Hello,
when I use list.files with recursive = TRUE and all.files = TRUE, R returns
a list of strings/paths.
>From all those strings I want to keep only the ones starting with a .
I tried using grep to achieve that. However, the problem is that because of
the recursive list.files parameter,
for some files beginning with a . there is a path attached. I think it is
not as simple as it looks