How to sourceSearch and sourceExtract with case-insensitve text

I currently have both searching for “*brandnames*” but it is case-sensitive and ignoring instances of Brandnames and BrandNames

How can I make both case-insensitive?

Currently this can not be done, but I added it to our todo list. Very soon you can achieve this with regular expressions. I will update this post with more details once the feature is available.

1 Like

Same issue as here: sourceSearch: regex with mode or flags

This issue is solved with the latest update: https://ui.vision/home/whatsnew#5.2.3

For case insensitve source code search, use this regular expression:

sourceSearch | regex=/brandnames/i

Here is a sample macro that searches our home page for “busy” with and without caps:

{
  "Name": "ignore case",
  "CreationDate": "2019-9-18",
  "Commands": [
    {
      "Command": "open",
      "Target": "https://ui.vision/",
      "Value": ""
    },
    {
      "Command": "sourceSearch",
      "Target": "regex=/busY/i",
      "Value": "i"
    },
    {
      "Command": "echo",
      "Target": "i=${i}",
      "Value": "green"
    }
  ]
}

Brilliant, this works great, thank you!

For SourceExtract I’m finding now it only extracts the word found where it used to extract the whole line. How can I tell it to do the same using regex?

For SourceExtract I’m finding now it only extracts the word found where it used to extract the whole line.

The new update should be 100% backwards compatible. If not, this would be a bug. Can you please give me an example of what does no longer work?

Ah okay. Here’s the old macro (I was using *brandname* for sourceSearch and sourceExtract)

{
  "Name": "01Scrape_LandingPage",
  "CreationDate": "2019-9-23",
  "Commands": [
    {
      "Command": "store",
      "Target": "fast",
      "Value": "!replayspeed"
    },
    {
      "Command": "store",
      "Target": "true",
      "Value": "!errorignore"
    },
    {
      "Command": "open",
      "Target": "https://www.mywebsite.com/?cor=gb",
      "Value": ""
    },
    {
      "Command": "sourceSearch",
      "Target": "*brandname*",
      "Value": "brandnameCount"
    },
    {
      "Command": "store",
      "Target": "1",
      "Value": "loopcounter"
    },
    {
      "Command": "while_v2",
      "Target": "(${loopcounter} <=${brandnameCount})",
      "Value": "brandnameCount"
    },
    {
      "Command": "sourceExtract",
      "Target": "*brandname*@${LoopCounter}",
      "Value": "!csvLine"
    },
    {
      "Command": "csvSave",
      "Target": "01_LandingPage_brandnamementions_${brandnameCount}",
      "Value": ""
    },
    {
      "Command": "storeEval",
      "Target": "${LoopCounter}+1",
      "Value": "loopcounter"
    },
    {
      "Command": "endWhile",
      "Target": "",
      "Value": ""
    }
  ]
}

This would count the instances of “brandname” (but case-sensitive) then extract them with their full line to the csv, in quotes, like this:
" <li><img class=""lazy"" data-original=""https://cdn2.rcstatic.com/images/rclogo/blue/1x/wordmark-rclogo_122x26.png"" alt=""brandname"" src=""https://cdn2.rcstatic.com/images/site_graphics/newsite/rc-preload-transparent.gif"" style=""""></li>"

Using the case insensitive regex version just returns each instance of brandname, Brandname, BrandName and BRANDNAME but without the quotes or anything else

If it’s helpful at all, using the old method (*brandname*) still works in the same way as it used to

Oh, but that means with regex= it never worked, or?

So the question is really: What regex do I need to get the same result as with brandname, but case insensitive. Correct?

Doh! Sorry, I temporarily forgot the meaning of backwards compatibility.
I can’t say for sure if regex extracts only ever returned the word not the line, since I only tried with case-insensitive regex which never found anything.

But ultimately yes, what I’m asking is " What regex do I need to get the same result as with *brandname* , but case insensitive ."