I want to check if a character can be safely converted to a numeric by using a regex.
However, I don't see my error. Example:
stringr::str_detect("4.", pattern = "-{0,1}[0-9]+(.[0-9]+){0,1}")
This produces a TRUE
. My intention was to specifiy that whenever a .
follows the first sequence of numbers, there must be at least one other number, therefore (.[0-9]+){0,1}
.
What's wrong here?