Quick guidance on regex please

I’m trying to use sourceExtract to pull the ID value MYpKGJNUYQQVAvGu8km6G4 out of the page source. The value is embedded in the text string

videosUuids":["MYpKGJNUYQQVAvGu8km6G4"]

My best guess doesn’t work regex=videosUuids":["(.*?)"]. This pulls the entire string. I only need the ID value. (please refer to the image as this editor strips out the escape characters)

Solution: the fix here is to tack @1,1 on the end of the regex command. This will return the ID value. Without this, the whole string is returned.

I ran my code through regex101 and it works! The same code in sourceExtract doesn’t work as expected… what am I doing wrong?

Your regular expression works ok, but you need to tell the RPA software to use Match1,Group1 => You do this by adding @1,1 behind the regex.

My test macro works - it runs on this forum post :smiley:

{
  "Name": "regex1",
  "CreationDate": "2020-4-8",
  "Commands": [
    {
      "Command": "open",
      "Target": "https://forum.ui.vision/t/quick-guidance-on-regex-please/4923",
      "Value": ""
    },
    {
      "Command": "sourceExtract",
      "Target": "regex=videosUuids\\\"\\:\\[\\\"(.*?)\\\"\\]@1,1",
      "Value": "r"
    },
    {
      "Command": "echo",
      "Target": "r=${r}",
      "Value": "green"
    }
  ]
}

See also How do you use Regex capture groups