On Wed, 12 Jun 2019 15:45:04 +1000 nevil amos <nevil.a...@gmail.com> wrote:
> # my desired desired output: > # [1] "" "(B)" "(C)" (function(s) regmatches( s, gregexpr('\\([^)]+\\)', s) ))(c("ABC","A(B)C","AB(C)")) # [[1]] # character(0) # # [[2]] # [1] "(B)" # # [[3]] # [1] "(C)" This matches all substrings that start with an ( and are followed by non-zero amount of non-) characters, then terminated by ). If there are multiple such substrings, all are returned. -- Best regards, Ivan ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.