0

I'm using the RegEx practice tool to work on some web scraping.

https://extendsclass.com/regex-tester.html

(Laboratory Confirmed Cases )([clastexwid\-.\"= h<>\/]+)([0-9]+)/s This is what I'm searching for.

These are what I'm searching.

<td class="text-white">Laboratory Confirmed Cases </td>

<td class="text-white">1264450</td>

If I put the text to be searched on the same line, there is a match. If not then there is no match.

Help?

I'm using Google Apps Script/Javascript.

OneLeif
  • 13
  • 3
  • Does this answer your question? [Match line break with regular expression](https://stackoverflow.com/questions/5200353/match-line-break-with-regular-expression) – B001ᛦ Jul 17 '21 at 20:26
  • no, they're looking to do something to the end of the first line. I want to include more than one line in my search string. – OneLeif Jul 17 '21 at 20:43
  • I'm trying to follow this article: https://interdigitizer.medium.com/scrape-and-save-data-to-google-sheets-with-apps-script-7e3c0ccec96b – OneLeif Jul 17 '21 at 20:49

1 Answers1

0

You need to use \n? which indicates that there might be a new line.

Something like this could work -

Laboratory Confirmed Cases <\/td>\n?<td class="text-white">(\d+)<\/td>

as seen here -

https://regex101.com/r/QBDh57/1

this will return the confirmed case numbers.

or depending on if the text is trimmed() or stripped() you might need two (\n?\n?) of them.

Nefariis
  • 3,451
  • 10
  • 34
  • 52