Special Characters match in REGEXP_MATCH

204 views
Skip to first unread message

Rohit Lalwani

unread,
May 25, 2022, 9:15:36 AM5/25/22
to Google Ads API and AdWords API Forum
Hello there,

I am trying to match campaign names with special characters like [,] etc.

My regular expression is campaign.name REGEXP_MATCH '(?i).*\[.*'
But when I try to get data using this regular expression, it gives me error saying that it is invalid (BAD_VALUE).

I have checked that Google Ads uses RE2 syntax for regular expression and I have verified that the above expression is valid.
I have also checked this regular expression in google sheets and it works fine there.

Could you let me know how I can achieve the said result through regular expression?

Thanks & Regards

Google Ads API Forum Advisor

unread,
May 26, 2022, 2:02:07 AM5/26/22
to adwor...@googlegroups.com

Hi Rohit,
 

Thanks for reaching out to the Google Ads API Support team.
 

With regard to your concern, so our team can better check this concern, could you provide the complete Ads API logs (request and response with request-id) to further investigation on this?


You can provide it via Reply privately to the author option. If this option is not available, then send it instead on this email address googleadsa...@google.com.


Regards,

Google Logo
Darwin
Google Ads API Team
 


ref:_00D1U1174p._5004Q2bDMvC:ref

Rohit Lalwani

unread,
May 27, 2022, 6:14:07 AM5/27/22
to Google Ads API and AdWords API Forum
Hello Darwin and Google Ads API Team,

Thanks for the quick response.

I am happy to inform you that I am now able to escape special characters in regex in Google Ads API.  It's just that we have to escape with two backward-slash instead of one.

Earlier, I was using `SELECT campaign.name FROM campaign WHERE campaign.name REGEXP_MATCH '(?i).*\[.*'` which resulted in error called BAD_VALUE.
But now, I am instead using `SELECT campaign.name FROM campaign WHERE campaign.name REGEXP_MATCH '(?i).*\\[.*'` which works perfectly fine for all the special characters available.

Regards,
Rohit Lalwani

PS: The above regular expression gives us campaign names containing `[`
Reply all
Reply to author
Forward
0 new messages