All functions

str_to_upper() str_to_lower() str_to_title() str_to_sentence()

Convert case of a string.

invert_match()

Switch location of matches to location of non-matches.

fixed() coll() regex() boundary()

Control matching behaviour with modifier functions.

str_c()

Join multiple strings into a single string.

str_conv()

Specify the encoding of a string.

str_count()

Count the number of matches in a string.

str_detect()

Detect the presence or absence of a pattern in a string.

str_dup()

Duplicate and concatenate strings within a character vector.

str_extract() str_extract_all()

Extract matching patterns from a string.

str_flatten()

Flatten a string

str_glue() str_glue_data()

Format and interpolate a string with glue

str_length()

The length of a string.

str_locate() str_locate_all()

Locate the position of patterns in a string.

str_match() str_match_all()

Extract matched groups from a string.

str_order() str_sort()

Order or sort a character vector.

str_pad()

Pad a string.

str_remove() str_remove_all()

Remove matched patterns in a string.

str_replace() str_replace_all()

Replace matched patterns in a string.

str_replace_na()

Turn NA into "NA"

str_split() str_split_fixed()

Split up a string into pieces.

str_starts() str_ends()

Detect the presence or absence of a pattern at the beginning or end of a string.

str_sub() `str_sub<-`()

Extract and replace substrings from a character vector.

str_subset() str_which()

Keep strings matching a pattern, or find positions.

str_trim() str_squish()

Trim whitespace from a string

str_trunc()

Truncate a character string.

str_view() str_view_all()

View HTML rendering of regular expression match.

str_wrap()

Wrap strings into nicely formatted paragraphs.

sentences fruit words

Sample character vectors for practicing string manipulations.

word()

Extract words from a sentence.