Re: [R] Help with regex replacements

2023-06-27 Thread Chris Evans via R-help
Magic! tmp %>%   as_tibble() %>%   rename(Text = value) %>%   mutate(Text = str_replace_all(Text, fixed("."), "")) %>%   # filter(row_number() < 4) %>%   mutate(Text2 = gsub("((|/)[[:alnum:]]+)|(\\([[:alnum:]-]+\\))", "", Text)) Which (as you have already shown!) gave me this: # A

Re: [R] Help with regex replacements

2023-06-27 Thread Bert Gunter
OK, so you want parentheses, not "brackets" + I think I misinterpreted your specification, which I think is actually incomplete. Based on what I think you meant, how does this work: gsub("((|/)[[:alnum:]]+)|(\\([[:alnum:]-]+\\))", "",tmp$Text) [1] "Я досяг того, чого хотів" "Мені

Re: [R] Help with regex replacements

2023-06-27 Thread Bert Gunter
Does this do it for you (or get you closer): gsub("\\[.*\\]|[] |/ ","",tmp$Text) [1] "Я досяг того, чого хотів" [2] "Мені вдалося\nзробити бажане" [3] "Я досяг (досягла) того, чого хотів (хотіла)" [4] "Я\nдосяг(-ла) речей, яких хотілося досягти" [5] "Я досяг/ла того, чого\nхотів/ла" [6] "Я

Re: [R] Help with regex replacements

2023-06-27 Thread Chris Evans via R-help
Thanks Avi (I am a keen follower or your, and other stalwart helpers here). On 27/06/2023 18:27, avi.e.gr...@gmail.com wrote: Chris, Consider breaking up your task into multiple passes. Sorry, I could have explained more of what I had tried.  I never know how long to make things here. I

Re: [R] Help with regex replacements

2023-06-27 Thread avi.e.gross
Chris, Consider breaking up your task into multiple passes. And do them in whatever order preserves what you need. First, are you talking about brackets as in square brackets, or as in your example, parentheses? If you are sure you have no nested brackets, your requirement seems to be that