I was looking for an option to replace multiple patterns and found some answers in the first of below links. One of the suggested answers uses the stringr
package. I was interested to check options with stringi
and found one in the documentation (last example of second link) which is:
stri_replace_all_regex("The quicker brown fox jumped over the lazy dog.",
"\\b"%s+%c("quick", "brown", "fox")%s+%"\\b", c("slow", "black", "bear"), vectorize_all=FALSE)
Could someone explain how the %s+%
works here. I know about options to use %
, see, e.g., related questions mentioned in link 3 below. However, I could not figure out how this specific syntax works. Does this relate to piping, formatting (e.g. like in sprintf
), or the space regex? Could someone please explain how this works or point me to a resource where I can inform myself? I wasn´t sure what the meta-topic was, so I did not know where to look at in, e.g., regex manuals? Sorry, if this is an easy one and it turns out that I have just applied the wrong search strategy. Thank you.
My questions relates to the following links:
1: https://stackoverflow.com/questions/19424709/r-gsub-pattern-vector-and-replacement-vector
2: http://www.gagolewski.com/software/stringi/manual/?manpage=stri_replace
3: https://stackoverflow.com/questions/12730629/what-do-the-op-operators-in-mean-in-r-for-example-in