getex | R Documentation |
Extract of remove a substring matching a regular expression.
getex(x, pattern, ...)
x |
object from which strings are extracted. Will be coerced to a
character by |
pattern |
a regular expression whose matches in |
... |
other arguments passed to |
getex
and getex_
can work as a pair to gradually extract information
from a string.
getex
returns the substrings matched by pattern
in x
.
getex_
returns the portion of x
that is not matched.
library(magrittr)
# The following could be done with 'strsplit' but 'getex' can handle messier cases
progs <- c('SC BSc Honours Biology', 'Arts BA Ordinary Economics')
faculty <- progs %>% getex('^[^ ]+') %>% toupper
progs <- progs %>% getex_('^[^ ]+ ')
degree <- progs %>% getex('^[^ ]+')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.