Created
March 21, 2018 03:36
-
-
Save trinker/1c9fd675d830294c7e090982438e1132 to your computer and use it in GitHub Desktop.
regex: dynamix verbatim
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # test data | |
| before <- "A." | |
| after <- ".Z" | |
| x <- c("A.xyz.Z", "ABxyzYZ") | |
| pattern <- sprintf('(?<=\\Q%s\\E).*?(?=\\Q%s\\E)', before, after) | |
| which gives: | |
| > gregexpr(pattern, x, perl = TRUE) > 0 | |
| [1] TRUE FALSE | |
| #from https://stackoverflow.com/a/16225857/1000343 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment