stri_replace_fixed: Replace Occurrences of a Fixed Pattern

Description Usage Arguments Details Value See Also Examples

Description

Replaces with the given replacement string every/first/last substring of the input that matches the pattern.

Usage

1
2
3
4
5
stri_replace_all_fixed(str, pattern, replacement, opts_collator = list())

stri_replace_first_fixed(str, pattern, replacement, opts_collator = list())

stri_replace_last_fixed(str, pattern, replacement, opts_collator = list())

Arguments

str

character vector of strings to search in

pattern

character vector of patterns to search for

replacement

character vector of strings to replace with

opts_collator

a named list as generated with stri_opts_collator with Collator options, or NA for fast but locale-unaware byte comparison

Details

Vectorized over str, pattern, and replacement.

These functions scan the input string for matches of the pattern. Input that is not part of any match is left unchanged; each match is replaced in the result by the replacement string.

Pass opts_collator equal to NA for much faster, but locale unaware, (exact) byte comparisons. For natural language text this may be not what you really want.

Value

character vector

See Also

Other locale_sensitive: stri_cmp, stri_compare; stri_count_fixed; stri_detect_fixed; stri_enc_detect2; stri_locate_all_fixed, stri_locate_all_fixed,, stri_locate_first_fixed, stri_locate_first_fixed,, stri_locate_last_fixed, stri_locate_last_fixed; stri_opts_collator; stri_order, stri_sort; stri_split_fixed, stri_split_fixed; stri_trans_tolower, stri_trans_totitle, stri_trans_toupper; stringi-locale; stringi-search-fixed

Other search_fixed: stri_count_fixed; stri_detect_fixed; stri_extract_all_fixed, stri_extract_all_fixed,, stri_extract_first_fixed, stri_extract_first_fixed,, stri_extract_last_fixed, stri_extract_last_fixed; stri_locate_all_fixed, stri_locate_all_fixed,, stri_locate_first_fixed, stri_locate_first_fixed,, stri_locate_last_fixed, stri_locate_last_fixed; stri_opts_collator; stri_split_fixed, stri_split_fixed; stringi-search-fixed; stringi-search

Other search_replace: stri_replace_all_charclass, stri_replace_all_charclass, stri_replace_first_charclass, stri_replace_first_charclass, stri_replace_last_charclass, stri_replace_last_charclass; stri_replace_all_regex, stri_replace_all_regex, stri_replace_first_regex, stri_replace_first_regex, stri_replace_last_regex, stri_replace_last_regex; stri_replace_all; stri_replace_first; stri_replace_last; stri_replace; stringi-search

Examples

1
2
3
4
5
6
## Not run: 
s <- "Lorem ipsum dolor sit amet, consectetur adipisicing elit."
stri_replace_all_fixed(s," ","#")
stri_replace_all_fixed(s,"o","0")

## End(Not run)

Example output

[1] "Lorem#ipsum#dolor#sit#amet,#consectetur#adipisicing#elit."
[1] "L0rem ipsum d0l0r sit amet, c0nsectetur adipisicing elit."

stringi documentation built on May 2, 2019, 4:54 p.m.