Home > Enterprise >  Try to importxml wildcard character function
Try to importxml wildcard character function

Time:04-19

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?

CodePudding user response:

'=IMPORTXML("url","//span[@class='circle-with-text grade-D']")'.replace(/D/,"A"); It's the only capital D.

CodePudding user response:

Use SUBSTITUTE.

As per the Help Docs:

SUBSTITUTE

Replaces 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 within text_to_search.

    • search_for will 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 replace search_for.

  • occurrence_number - [ OPTIONAL ] - The instance of search_for within text_to_search to replace with replace_with. By default, all occurrences of search_for are replaced; however, if occurrence_number is specified, only the indicated instance of search_for is replaced.

So:

=IMPORTXML("url",SUBSTITUTE("//span[@class='circle-with-text grade-D']", "D", "A"))

replaces all Ds in the formula with As.

  • Related