This helper function extracts one or more characters from a string using their byte positions. It converts the input string to raw bytes, selects the specified positions, and converts them back to a character.
Details
This is often faster and easier than splitting the string, subsetting, and pasting the string back together.
Note
This function operates at the raw byte level and may not behave as expected with multibyte or non-ASCII characters. For the purposes of this package, all validated sequence strings will only contain ASCII strings and this will work as expected.
Examples
extract_string_chars("hello", c(1, 2)) # Returns "he"
#> [1] "he"