Outdated operators

149 views
Skip to first unread message

Pascal van Dooren

unread,
Oct 20, 2022, 5:38:52 AM10/20/22
to Google Ads Scripts Forum
Hi,

With the introduction of the new Google Ads Scripts Experience some of the old operators have been sunset ("CONTAINS_IGNORE_CASE"). Using them will result in an error:

unrecognized operator "CONTAINS_IGNORE_CASE"

Instead we can now use the LIKE and REGEXP_MATCH operators for strings. However, these don't seem to be able to achieve the same goal. LIKE is case sensitive and I can't seem to get REGEXP_MATCH working with the case insensitive flag.

Could you please update the Google Ads Scripts documentation as they still refer to the old operators. Also I'd like to know how to select entities based on case-insensitive strings in the new experience.

Thanks in advance.


Pascal van Dooren

unread,
Oct 20, 2022, 5:44:37 AM10/20/22
to Google Ads Scripts Forum
Never mind, it seems LIKE does use case-insensitive matching. However, it would still be nice if the documentation was updated to reflect these changes.

Sigurd Fabrin

unread,
Oct 20, 2022, 8:43:12 AM10/20/22
to Google Ads Scripts Forum
"can't seem to get REGEXP_MATCH working with the case insensitive flag"

Try (?i) - like this:
let campaignPattern = 'Part of Campaign Name in Whatever CasE';
    let query =
        'SELECT '+
        'campaign.name '+
        'FROM campaign '+
        'WHERE '+
        'campaign.name REGEXP_MATCH "(?i).*'+campaignPattern+'.*"';
    let response = AdsApp.search(query);
    while (response.hasNext()) {
      let row = response.next();
      console.log(row.campaign.name)
    }


GAQL regex syntax: https://github.com/google/re2/wiki/Syntax & https://developers.google.com/google-ads/api/docs/query/grammar


Sigurd

Pascal van Dooren

unread,
Oct 24, 2022, 1:46:13 AM10/24/22
to Google Ads Scripts Forum
Thanks Sigurd! I found the documentation on how to use the flags quite unclear, but your solution fixes my problem.

Google Ads Scripts Forum Advisor

unread,
Oct 24, 2022, 9:58:34 AM10/24/22
to adwords...@googlegroups.com
Hello,

@Sigurd, thank you for clarifying the documentation. 

Please let us know if there are any further questions.

Regards,

Google Logo
Matt
Google Ads Scripts Team
 


ref:_00D1U1174p._5004Q2fnPaY:ref

Pascal van Dooren

unread,
Oct 27, 2022, 12:13:42 PM10/27/22
to Google Ads Scripts Forum
It seems there are still some issues with REGEXP_MATCH. I'd like to match campaigns with this pattern: (E). However, this does not seem to work, despite escaping the parentheses:

.*\(E\).*

I suppose there's some bug in the regex matching?

Sigurd Fabrin

unread,
Oct 28, 2022, 7:39:19 AM10/28/22
to Google Ads Scripts Forum
This should work: (.*)([(][E][)])(.*)

Explanation from: https://regex101.com/
Screenshot 2022-10-28 at 13.37.36.png


Sigurd

Message has been deleted

Pascal van Dooren

unread,
Nov 2, 2022, 7:06:27 AM11/2/22
to Google Ads Scripts Forum
Thanks a lot Sigurd. That seems to do the trick.

Another question. I'd like to match campaigns with a specific naming using the (NOT) LIKE operator. For example campaigns that contain '_DSA'. However, when I use the filter 'LIKE "%_DSA%"' it will treat the underscore as a wildcard. Using a backslash to escape the underscore will result in an error. I can't find anything about escaping for GAQL. Could you perhaps point me in the right direction again?

Sigurd Fabrin

unread,
Nov 3, 2022, 5:41:32 AM11/3/22
to Google Ads Scripts Forum
Yes, '_' is a wildcard. 

It seems GAQL doesn't support use of the ESCAPE keyword - where you'd define what character you use for escaping.

However, you can use wildcards as literals if you enclose them in brackets

Try this to match any campaign with this pattern"_DSA" using LIKE 
 - btw: note that LIKE is case insensitive in GAQL
'SELECT '+
      'campaign.name '+
 'FROM '+
      'campaign '+
 'WHERE +
      'campaign.name LIKE "%[_]dsa%"' // This works
   // 'campaign.name LIKE "%$_dsa%" ESCAPE "$"' // This doesn't work



Sigurd
Message has been deleted

Pascal van Dooren

unread,
Nov 3, 2022, 9:41:46 AM11/3/22
to Google Ads Scripts Forum
Thank you very much Sigurd, you've helped me out once again.
Reply all
Reply to author
Forward
0 new messages