Re: [R] gsub issue with consecutive pattern finds

2024-03-01 Thread Bert Gunter
Oh, wait a second. I misread your original post. Please ignore my truly incorrect suggestion. -- Bert On Fri, Mar 1, 2024 at 7:57 AM Bert Gunter wrote: > > Here's another *incorrect* way to do it -- incorrect because it will > not always work, unlike Iris's correct solution. But it does not > re

Re: [R] gsub issue with consecutive pattern finds

2024-03-01 Thread Bert Gunter
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

Re: [R] gsub issue with consecutive pattern finds

2024-03-01 Thread Iago Giné Vázquez
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])", "

Re: [R] gsub issue with consecutive pattern finds

2024-03-01 Thread Iris Simmons
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

[R] gsub issue with consecutive pattern finds

2024-03-01 Thread Iago Giné Vázquez
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 (a