search for: lookarounds

Displaying 7 results from an estimated 7 matches for "lookarounds".

Did you mean: lookaround
2024 Mar 01
1
gsub issue with consecutive pattern finds
Hi Iago, This is not a bug. It is expected. Patterns may not overlap. However, 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
2024 Mar 01
1
gsub issue with consecutive pattern finds
Hi Iris, Thank you. Further, very nice solution. Best, Iago On 01/03/2024 12:49, Iris Simmons wrote: > Hi Iago, > > > This is not a bug. It is expected. Patterns may not overlap. However, there > is a way to get the result you want using perl: > > ```R > gsub("([aeiouAEIOU])(?=[aeiouAEIOU])", "\\1_", "aerioue", perl = TRUE) > ``` >
2024 Mar 01
1
gsub issue with consecutive pattern finds
Here's another *incorrect* way to do it -- incorrect because it will not always work, unlike Iris's correct solution. But it does not require PERL type matching. The idea: separate the two vowels in the regex by a character that you know cannot appear (if there is such) and match it optionally, e.g. with '*" repetition specifier. I used "?" for the optional character
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 express...
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)