'Try to importxml wildcard character function
I am using importxml function to extract some info
=IMPORTXML("url","//span[@class='circle-with-text grade-D']")
I need to replace D with any other letter,trying to use "" or '' or '?' etc with no results. "AN?" idea?
Solution 1:[1]
'=IMPORTXML("url","//span[@class='circle-with-text grade-D']")'.replace(/D/,"A"); It's the only capital D.
Solution 2:[2]
Use SUBSTITUTE.
As per the Help Docs:
SUBSTITUTEReplaces existing text with new text in a string.
SUBSTITUTE(text_to_search, search_for, replace_with, [occurrence_number])
text_to_search- The text within which to search and replace.
search_for- The string to search for withintext_to_search.
search_forwill match parts of words as well as whole words; therefore a search for"vent"will also replace text within"eventual".
replace_with- The string that will replacesearch_for.
occurrence_number- [ OPTIONAL ] - The instance ofsearch_forwithintext_to_searchto replace withreplace_with. By default, all occurrences ofsearch_forare replaced; however, ifoccurrence_numberis specified, only the indicated instance ofsearch_foris replaced.
So:
=IMPORTXML("url",SUBSTITUTE("//span[@class='circle-with-text grade-D']", "D", "A"))
replaces all Ds in the formula with As.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Cooper |
| Solution 2 |
