Skip to contents

Lookup digits in a string, either text (e.g., 'one', 'two', ...) or numerical characters. Once it finds the first digit it returns it.

Usage

lookup_digit(x, backwards = FALSE)

Arguments

x

Input string with digits.

backwards

Flag to indicate the direction of search, if TRUE, then look up digits backwards, otherwise, just find the first digit in the string.

Value

String with numeric digit

Examples

lookup_digit("m9qvkqlgfhtwo3seven4seven")
#> [1] "9"
lookup_digit("m9qvkqlgfhtwo3seven4seven", TRUE)
#> [1] 7