user17710367
user17710367

Reputation:

Using gspread, trying to color many strings

In google sheets, I am trying to find many strings and highlight them, so say, "Find", "Find2", "Find3", "Find4". Please see below.

cell_list = worksheet.findall("find", "find2", "find3", "find4")

Upvotes: 0

Views: 42

Answers (1)

Tanaike
Tanaike

Reputation: 201428

In that case, how about the following modification?

From:

cell_list = worksheet.findall("find", "find2", "find3", "find4")

To:

regex = re.compile("find|find2|find3|Find4")
cell_list = worksheet.findall(regex)

and

regex = re.compile("find(\d+)?", re.IGNORECASE)
cell_list = worksheet.findall(regex)

In this modification, the regex is used for findall.

Reference:

gspread API Reference - findall

Upvotes: 1

Related Questions