Background
I know how to extract all numbers from an alphanumeric string using functions like TEXTJOIN()
and SUBSTITUTE()
etc. However, I'd be interested in a non-array entered way and thought it might be done through FILTERXML()
as I'm trying to learn a bit more on the topic.
Excel's FILTERXML()
function is available from Excel 2013 onwards (not online or Mac) and supports XPATH 1.0
. Therefor I tried to implement the double translate() trick as can be found here.
Question
So how would one go about translating all non-numeric characters a string using the double translate()
function through XPATH
in Excel?
| Sample | Desired Output |
|-----------|----------------|
| aBc1d5_x9 | 159 |
| 12:2&0 | 1220 |
| ABC123 | 123 |
I tried: =FILTERXML("<t><s>"&A2&"</s></t>","//s[translate(.,translate(.,'0123456789',''),'')]")
. However, this returns the exact same value as A2
(nothing changed). Unsupported XPATH
functions or faulty syntax normally would return a #VALUE
error. So this looks like it is indeed supported yet somewhere in my syntax I went wrong, but I'm out of guesses.