I've been trying to extract decimal numbers from strings in sparklyr, but it does not work with the regular syntax you would normally use outside of Spark.
I have tried using regexp_extract but it returns empty strings.
regexp_extract($170.5M, "[[:digit:]]+\\.*[[:digit:]]*")
I'm trying to get 170.5 as a result.
You could use regexpr
from base R
v <- "$170.5M"
regmatches(v, regexpr("\\d*\\.\\d", v))
# [1] "170.5"