| splitByPattern | R Documentation |
Splits a single character string by pattern. The main difference compared to strsplit()
is that this method also returns the part of the string that matched
the pattern. Also, it only takes a single character string.
## Default S3 method:
splitByPattern(str, pattern, ...)
str |
A single |
pattern |
A regular expression |
... |
Not used. |
Returns a named character vector with names equal to "TRUE"
if element is a pattern part and "FALSE" otherwise.
Henrik Bengtsson
Compare to strsplit().
rspCode <- "<body>Hello <%=\"world\"%></body>"
rspParts <- splitByPattern(rspCode, pattern="<%.*%>")
cat(rspCode, "\n")
print(rspParts)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.