How to use regex to extract all expected values

hi team,

issue: how to use regex to extract all the expected values please? for now, i have multiple results meet my regex syntax. the syntax will always extract the first result by default but i expect all the values. could i extract all of them at one go please?

e.g.
the websites:
Capture

my command:
“Command”: “sourceExtract”,
“Target”: “Regex=(?<=<span class=“tab-text”>)(.+?)(?=)”,
“Value”: “v1”
},
{
“Command”: “echo”,
“Target”: “${v1}”,
“Value”: “”

it will always return :“Hardware”, but i need all,“Hardware”,“Accessories”,“Care Packs”.

thank you for guiding me.

You can use the@n symbol to get the n-th match.

As example, see this sourceExtract example from the docs:

sourceExtract | $*</li>@2 => gets $1.95 (the tea)

So in your case you will have

Regex=(?<=)(.+?)(?=)@${n}

and then make a loop to change ${n} from 1 to 3. In general you would simply increase N until no more matches are found. In sourceExtract, if no match is found, variable is set to “#nomatchfound” - and no error is triggered. So you stop the loop once the web scraping result is the string “#nomatchfound”.

@ulrich
hi, thank you so much for the guidance.
yes, i have achieved my goal. and let me share the script here in case someone met a same problem.

"Command": "store",
  "Target": "1",
  "Value": "n"
},
{
  "Command": "label",
  "Target": "loopbegin",
  "Value": "<<<<<<<<<<<<<"
},
{
  "Command": "sourceExtract",
  "Target": "regex=(?<=<span class=\"tab-text\">)(.+?)(?=</span>)@${n}",
  "Value": "tabname"
},
{
  "Command": "if_v2",
  "Target": "${tabname}!=\"#nomatchfound\"",
  "Value": ""
},
{
  "Command": "store",
  "Target": "${!COL1} the tabs are {${tabname} ",
  "Value": "!csvLine"
},
{
  "Command": "csvSave",
  "Target": "test.csv\t",
  "Value": ""
},
{
  "Command": "storeEval",
  "Target": "${n}+1",
  "Value": "n"
},
{
  "Command": "gotoIf_v2",
  "Target": "${n}<20",
  "Value": "loopbegin"
},
{
  "Command": "endif",
  "Target": "",
  "Value": ""
}

]
}