2

I'm wondering what regex pattern I could use to detect if every character in a string is numeric.

So, here's what I'm thinking that isn't working:

stringr::str_detect("311apple", "[0-9]")
#> [1] TRUE

That statement is TRUE because there exists a numeric character in that string, but I'm trying to find a pattern so that it's only TRUE if every character is numeric.

Any ideas? Thanks!

Evan O.
  • 1,553
  • 2
  • 11
  • 20

0 Answers0