Home > Net >  Extract Substrings using importxml in google sheets
Extract Substrings using importxml in google sheets

Time:01-03

Using IMPORTXML in google sheets. I want to extract part of the result into one cell.

=IMPORTXML(B1,"//div[@class='orca-rating SwtJyda color-yellow tbody-6']/span")

I got the result spread over several columns. B8:F8 result spread to B8:F8

The inspect element is like this. I only want the value "2". It is in cell B8. inspect element

I think this can be done using substring-after. But I could not get the correct result.

CodePudding user response:

In your situation, how about the following samples?

=REGEXREPLACE(JOIN("",IMPORTXML(B1,"//div[@class='orca-rating SwtJyda color-yellow tbody-6']/span")),"[^0-9]","")
=REGEXEXTRACT(JOIN("",IMPORTXML(B1,"//div[@class='orca-rating SwtJyda color-yellow tbody-6']/span")),"\((.*)\)")

References:

CodePudding user response:

I use this formula. That works too.

=INDEX(  IMPORTXML(B1,"//div[@class='orca-rating SwtJyda color-yellow tbody-6']/span"),3)

But tanaike's formula is very good.

  • Related