How to get all possible combinations from the following regex pattern?
"(ost|west)europäisch(*$|e(*$|r|s|n|m))"
I would like getting a vector that looks like this:
[1] "osteuropäisch" "westeuropäisch" "osteuropäische" "westeuropäische"
[5] "osteuropäischer" "westeuropäischer" "osteuropäisches" "westeuropäisches"
[9] "osteuropäischen" "westeuropäischen" "osteuropäischem" "westeuropäischem"
From the following question, I understand that I can get all combinations with the following function:
do.call(paste0, expand.grid(
c("ost","west"),
"europäisch",
c("", paste0("e", c("", "r", "s", "n", "m"))))
)
However, I have a large number of different regex patterns that I need to convert into full strings. Therefore, I was wondering if there is anywhere a function or package for R that can transform regex expressions into a vector of all possible combinations.
So far I have not found any explicit function in base
, stringi
or stringr
From a similar question on regex combinations in python, I know that for python the exrex module exists. I was thinking that maybe something similar exists for R, which I am not able to find?