Skip to content

Instantly share code, notes, and snippets.

@trinker
Created March 21, 2018 03:36
Show Gist options
  • Select an option

  • Save trinker/1c9fd675d830294c7e090982438e1132 to your computer and use it in GitHub Desktop.

Select an option

Save trinker/1c9fd675d830294c7e090982438e1132 to your computer and use it in GitHub Desktop.
regex: dynamix verbatim
# 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