Skip to main content Module strings Copy item path Source FmtSpec ๐ Parsed format specifier from a sprintf format string. StringError Structured error type for string operations. __BUILTIN_REG_BUILTIN_AGREP ๐ __BUILTIN_REG_BUILTIN_AGREPL ๐ __BUILTIN_REG_BUILTIN_AS_RAW ๐ __BUILTIN_REG_BUILTIN_BASENAME ๐ __BUILTIN_REG_BUILTIN_CASEFOLD ๐ __BUILTIN_REG_BUILTIN_CHARTR ๐ __BUILTIN_REG_BUILTIN_CHAR_TO_RAW ๐ __BUILTIN_REG_BUILTIN_DEPARSE ๐ __BUILTIN_REG_BUILTIN_DEPARSE1 ๐ __BUILTIN_REG_BUILTIN_DIRNAME ๐ __BUILTIN_REG_BUILTIN_DQUOTE ๐ __BUILTIN_REG_BUILTIN_ENC2NATIVE ๐ __BUILTIN_REG_BUILTIN_ENC2UTF8 ๐ __BUILTIN_REG_BUILTIN_ENCODE_STRING ๐ __BUILTIN_REG_BUILTIN_ENCODING ๐ __BUILTIN_REG_BUILTIN_ENDS_WITH ๐ __BUILTIN_REG_BUILTIN_FORMAT_C ๐ __BUILTIN_REG_BUILTIN_FORMAT_PVAL ๐ __BUILTIN_REG_BUILTIN_GETTEXT ๐ __BUILTIN_REG_BUILTIN_GETTEXTF ๐ __BUILTIN_REG_BUILTIN_GLOB2RX ๐ __BUILTIN_REG_BUILTIN_GREGEXPR ๐ __BUILTIN_REG_BUILTIN_GREP ๐ __BUILTIN_REG_BUILTIN_GREPL ๐ __BUILTIN_REG_BUILTIN_GSUB ๐ __BUILTIN_REG_BUILTIN_ICONV ๐ __BUILTIN_REG_BUILTIN_INT_TO_UTF8 ๐ __BUILTIN_REG_BUILTIN_IS_RAW ๐ __BUILTIN_REG_BUILTIN_MAKE_NAMES ๐ __BUILTIN_REG_BUILTIN_MAKE_UNIQUE ๐ __BUILTIN_REG_BUILTIN_NGETTEXT ๐ __BUILTIN_REG_BUILTIN_NZCHAR ๐ __BUILTIN_REG_BUILTIN_PRETTY_NUM ๐ __BUILTIN_REG_BUILTIN_RAW ๐ __BUILTIN_REG_BUILTIN_RAW_SHIFT ๐ __BUILTIN_REG_BUILTIN_RAW_TO_CHAR ๐ __BUILTIN_REG_BUILTIN_REGEXEC ๐ __BUILTIN_REG_BUILTIN_REGEXPR ๐ __BUILTIN_REG_BUILTIN_REGMATCHES ๐ __BUILTIN_REG_BUILTIN_REGMATCHES_ASSIGN ๐ __BUILTIN_REG_BUILTIN_SPRINTF ๐ __BUILTIN_REG_BUILTIN_SQUOTE ๐ __BUILTIN_REG_BUILTIN_STARTS_WITH ๐ __BUILTIN_REG_BUILTIN_STRREP ๐ __BUILTIN_REG_BUILTIN_STRSPLIT ๐ __BUILTIN_REG_BUILTIN_STRTOI ๐ __BUILTIN_REG_BUILTIN_STRTRIM ๐ __BUILTIN_REG_BUILTIN_STRWRAP ๐ __BUILTIN_REG_BUILTIN_SUB ๐ __BUILTIN_REG_BUILTIN_SUBSTR ๐ __BUILTIN_REG_BUILTIN_SUBSTR_ASSIGN ๐ __BUILTIN_REG_BUILTIN_SYS_GETLOCALE ๐ __BUILTIN_REG_BUILTIN_SYS_SETLOCALE ๐ __BUILTIN_REG_BUILTIN_TOLOWER ๐ __BUILTIN_REG_BUILTIN_TOUPPER ๐ __BUILTIN_REG_BUILTIN_TO_STRING ๐ __BUILTIN_REG_BUILTIN_TRIMWS ๐ __BUILTIN_REG_BUILTIN_TYPE_CONVERT ๐ __BUILTIN_REG_BUILTIN_URLDECODE ๐ __BUILTIN_REG_BUILTIN_URLENCODE ๐ __BUILTIN_REG_BUILTIN_UTF8_TO_INT ๐ __INTERP_REG_INTERP_DPUT ๐ approximate_contains ๐ Check whether haystack contains a substring approximately matching needle
within the given maximum edit distance. Uses a sliding-window approach:
for each window of length needle.len() +/- max_dist, compute Levenshtein distance. build_fixed_searcher ๐ Build an AhoCorasick automaton for a single fixed pattern, optionally case-insensitive.
This builds the automaton once and amortizes the cost across many haystack searches. build_regex ๐ builtin_agrep ๐ Approximate grep: search for approximate pattern matches in a character vector. builtin_agrepl ๐ Approximate grepl: test whether a pattern approximately matches each element. builtin_as_raw ๐ as.raw(x) โ coerce to raw (byte) values (0-255), truncating to lowest byte.builtin_basename ๐ Extract the file name from paths. builtin_casefold ๐ Convert case of a character vector. builtin_char_to_raw ๐ Convert a character string to a raw (byte) vector. builtin_chartr ๐ Translate characters in strings (character-by-character substitution). builtin_deparse ๐ Convert an R expression or value to its string representation. builtin_deparse1 ๐ Single-string deparse (R 4.0+). Collapses multi-line deparse output. builtin_dirname ๐ Extract the directory part from paths. builtin_dquote ๐ Wrap strings in double (typographic) quotes. builtin_enc2native ๐ Convert character vector to native encoding (passthrough in miniR). builtin_enc2utf8 ๐ Convert character vector to UTF-8 encoding (passthrough in miniR). builtin_encode_string ๐ Encode a character string with optional quoting, width, and justification. builtin_encoding ๐ Report the encoding of character strings. builtin_ends_with ๐ Test whether strings end with a given suffix. builtin_format_c ๐ Formatted printing of numbers and strings, similar to Cโs printf family. builtin_format_pval ๐ Format p-values for display, showing e.g. โ< 2.2e-16โ for very small values. builtin_gettext ๐ Translate a message (i18n stub โ returns the message unchanged). builtin_gettextf ๐ Format and translate a message (i18n stub โ delegates to sprintf). builtin_glob2rx ๐ Convert a glob (wildcard) pattern to a regular expression. builtin_gregexpr ๐ Find all matches of a pattern in each element of a character vector. builtin_grep ๐ Search for pattern matches in a character vector. builtin_grepl ๐ Test whether a pattern matches each element of a character vector. builtin_gsub ๐ Replace all occurrences of a pattern in character strings. builtin_iconv ๐ Convert character strings between encodings. builtin_int_to_utf8 ๐ Convert integer Unicode code points to a UTF-8 string. builtin_is_raw ๐ is.raw(x) โ test if argument is a raw vector.builtin_make_names ๐ Make syntactically valid R names from character strings. builtin_make_unique ๐ Make character strings unique by appending sequence numbers to duplicates. builtin_ngettext ๐ Translate a message with singular/plural forms (i18n stub). builtin_nzchar ๐ Test whether character strings are non-empty. builtin_pretty_num ๐ Format numbers with separators for readability (e.g., thousand separators). builtin_raw ๐ raw(length) โ create a raw (byte) vector of zeros.builtin_raw_shift ๐ rawShift(x, n) โ bitwise shift of raw (byte) values.
Positive n shifts left, negative n shifts right.builtin_raw_to_char ๐ Convert a raw (byte) vector to a character string. builtin_regexec ๐ Match a pattern with capture groups against a character vector. builtin_regexpr ๐ Find the first match of a pattern in each element of a character vector. builtin_regmatches ๐ Extract matched substrings from regexpr/gregexpr results. builtin_regmatches_assign ๐ Replace matched substrings using regexpr/gregexpr match data. builtin_sprintf ๐ Format strings using C-style format specifiers, vectorized over arguments. builtin_squote ๐ Wrap strings in single (typographic) quotes. builtin_starts_with ๐ Test whether strings start with a given prefix. builtin_strrep ๐ Repeat each element of a character vector a specified number of times. builtin_strsplit ๐ Split strings by a pattern or fixed delimiter. builtin_strtoi ๐ Convert strings to integers using a specified base (radix). builtin_strtrim ๐ Trim character strings to a specified display width. builtin_strwrap ๐ Wrap character strings to a specified width. builtin_sub ๐ Replace the first occurrence of a pattern in character strings. builtin_substr ๐ Extract substrings from character strings. builtin_substr_assign ๐ Replace substrings in character strings. builtin_sys_getlocale ๐ Get the current locale setting (stub โ returns โCโ locale). builtin_sys_setlocale ๐ Set the locale (stub โ accepts but ignores the setting). builtin_to_string ๐ Collapse a vector into a single comma-separated string. builtin_tolower ๐ Convert strings to lower case. builtin_toupper ๐ Convert strings to upper case. builtin_trimws ๐ Remove leading and/or trailing whitespace from strings. builtin_type_convert ๐ Auto-convert character vector to appropriate type. builtin_urldecode ๐ Decode percent-encoded URL strings. builtin_urlencode ๐ Percent-encode URL strings per RFC 3986. builtin_utf8_to_int ๐ Convert a UTF-8 string to integer Unicode code points. collect_fmt_specs ๐ Collect the format specifiers from a format string, returning a list of
(FmtSpec, arg_index) pairs (0-based among the data args, i.e. excluding fmt). convert_replacement ๐ Convert R-style replacement backreferences (\1, \2) to regex crate style ($1, $2) fixed_gsub ๐ Replace all occurrences of needle in haystack with replacement. fixed_split ๐ Split haystack on all occurrences of needle. format_g ๐ Format using %g/%G: use shorter of %f and %e, removing trailing zeros. format_scientific ๐ Format a float in scientific notation matching Rโs output (two-digit exponent minimum). get_regex_opts ๐ Extract common regex options from named args: fixed, ignore.case, perl iconv_one ๐ Convert a single string between encodings using bstr for byte-level access. insert_marks ๐ Insert big_mark every 3 digits before the decimal point and small_mark
every 3 digits after the decimal point. interp_dput ๐ Write a deparsed representation of an R object to stdout. levenshtein_distance ๐ Compute the Levenshtein edit distance between two strings.
Uses a single-row DP approach (O(min(m,n)) space). normalize_encoding_name ๐ Normalize an encoding name to a canonical form. parse_fmt_spec ๐ Parse a format specifier starting after โ%โ. Returns (FmtSpec, chars consumed). parse_max_distance ๐ Parse Rโs max.distance argument for agrep/agrepl.
R accepts either a single numeric (fraction of pattern length if < 1, absolute if >= 1)
or a named list. We support the simple numeric case. sprintf_one ๐ Format one string from the format template, using element elem_idx from
each data-arg vector (with recycling). translate_pcre_to_rust ๐ Build a compiled regex from a pattern string, respecting fixed and ignore.case options.
Returns Err(RError) if the pattern is invalid regex.
Translate R/PCRE regex patterns to Rust regex syntax. trim_to_width ๐ Trim a string to at most max_width display columns.