Skip to contents

Extract all numbers from a string

Usage

extract_numbers(x)

Arguments

x

character. The string to extract numbers from.

Value

A numeric vector containing all numbers in the string.

Examples

extract_numbers("abc123def456")
#> [1] 123 456
extract_numbers("Game 1:")
#> [1] 1
extract_numbers("Cards: 1 3 16 136")
#> [1]   1   3  16 136
extract_numbers("1, -3, 16, -136")
#> [1]    1   -3   16 -136