Xpath - extract only numbers

2k views Asked by At

Using Xpath in Google Docs spreadsheet, I need to extract only the numbers (digits) from a containing both text and numbers using Xmlimport. I've been trying to find a solution on stackoverflow and google, but so far unsuccessful.

This is what I have in the field I2 in the spreadsheet:

=IMPORTXML(J2; "//*[@id='tab-1411393574769-10']/div[2]/div/table[1]/tbody/tr[2]/td[2]")

so far it returns this string: 152 text

I really need it to return only: 152

How would I construct this command in Google Docs? I tried putting SUM() around the entire thing to see if it would return just the digits, but it returns: 0

Thank you.

1

There are 1 answers

2
JPV On BEST ANSWER

try extracting the digits with regexextract and see if that works ?

=REGEXEXTRACT(IMPORTXML(J2; "//*[@id='tab-1411393574769-10']/div[2]/div/table[1]/tbody/tr[2]/td[2]"); "(\d+)")