Displaying 7 results from an estimated 7 matches for "lookaround".
2024 Mar 01
1
gsub issue with consecutive pattern finds
...er, there
is a way to get the result you want using perl:
```R
gsub("([aeiouAEIOU])(?=[aeiouAEIOU])", "\\1_", "aerioue", perl = TRUE)
```
The specific change I made is called a positive lookahead, you can read
more about it here:
https://www.regular-expressions.info/lookaround.html
It's a way to check for a piece of text without consuming it in the match.
Also, since you don't care about character case, it might be more legible
to add ignore.case = TRUE and remove the upper case characters:
```R
gsub("([aeiou])(?=[aeiou])", "\\1_", "ae...
2024 Mar 01
1
gsub issue with consecutive pattern finds
...ant using perl:
>
> ```R
> gsub("([aeiouAEIOU])(?=[aeiouAEIOU])", "\\1_", "aerioue", perl = TRUE)
> ```
>
> The specific change I made is called a positive lookahead, you can read
> more about it here:
>
> https://www.regular-expressions.info/lookaround.html
>
> It's a way to check for a piece of text without consuming it in the match.
>
> Also, since you don't care about character case, it might be more legible
> to add ignore.case = TRUE and remove the upper case characters:
>
> ```R
> gsub("([aeiou])(?=[aeio...
2024 Mar 01
1
gsub issue with consecutive pattern finds
...> gsub("([aeiouAEIOU])(?=[aeiouAEIOU])", "\\1_", "aerioue", perl = TRUE)
> > ```
> >
> > The specific change I made is called a positive lookahead, you can read
> > more about it here:
> >
> > https://www.regular-expressions.info/lookaround.html
> >
> > It's a way to check for a piece of text without consuming it in the match.
> >
> > Also, since you don't care about character case, it might be more legible
> > to add ignore.case = TRUE and remove the upper case characters:
> >
> > ```...
2024 Mar 01
1
gsub issue with consecutive pattern finds
Hi all,
I tested next command:
gsub("([aeiouAEIOU])([aeiouAEIOU])", "\\1_\\2", "aerioue")
with the following output:
[1] "a_eri_ou_e"
So, there are two consecutive vowels where an underscore is not added.
May it be a bug? Is it expected (bug or not)? Is there any chance to get
what I want (an underscore between each pair of consecutive vowels)?
2006 Aug 16
0
Regular expressions: retrieving matches depending on intervening strings [Follow-up]
...rts<-unlist(matches)
lengths<-unlist(sapply(matches, attributes))
stops<-starts+lengths-1
substr(a, starts, stops)
What is still missing is that the disallowed string is not just "<[wc]" but "<[wc] " and I don't know how to do that. Any ideas (preferably with lookarounds)?
Thanks a bunch,
STG
--
Stefan Th. Gries
-----------------------------------------------
University of California, Santa Barbara
http://www.linguistics.ucsb.edu/faculty/stgries
-----------------------------------------------
ORIGINAL MESSAGE
> Dear all
>
> I again have a regular expres...
how to count the total number of (INCLUDING overlapping) occurrences of a substring within a string?
2009 Dec 20
1
how to count the total number of (INCLUDING overlapping) occurrences of a substring within a string?
Last one for you guys:
The command:
length(gregexpr('cus','hocus pocus')[[1]])
[1] 2
returns the number of times the substring 'cus' appears in 'hocus pocus'
(which is two)
It's returning the number of **disjoint** matches. So:
length(gregexpr('aa','aaa')[[1]])
[1] 1
returns 1.
**What I want to do:**
I'm looking for a way to count
2006 Oct 07
2
gregexpr in R 2.3.0 != gregexpr in R 2.4.0
Hi all
I have a question regarding differences in the way gregpexr works in R 2.3.0 and R 2.4.0.
In R 2.3.0, this is what happens:
> gregexpr(" [a-z] [a-z] ", " a b c d e f ", perl=T)
[[1]]
[1] 1 3 5 7 9
attr(,"match.length")
[1] 5 5 5 5 5
... while in R 2.4.0, this is what happens:
> gregexpr(" [a-z] [a-z] ", " a b c d e f ", perl=T)