On Tue, 17 Sep 2019 10:14:24 +0300 Ivan Krylov <krylov.r...@gmail.com> wrote:
> '\\[.*\\]' Sorry, I forgot to take it into account that you don't want the [] in your units, either. That's still doable, but requires so-called look-around assertions in the regular expression: '(?<=\\[).*(?=\\])' This should match any characters that are preceded by "[" and followed by "]", but without including the brackets in the match. This requires passing perl = TRUE to regexpr(). stringr::str_match() understands this pattern without any additional flags. -- 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.