On 19 October 2017 at 16:01,  <dombrowski.mich...@gmail.com> wrote:
> I add this for others having problems with non capture groups when using
> regular expressions in google scripts:
>
> I struggled trying to debug why this simple regex would not work for me in
> google application script: /(?:SKU\: \*)(\d*)/  [in this case i am trying to
> extract the SKU number from the body of an email].
>
> The results were nonsensical and I struggled off and on for a few days
> trying to resolve the issue while i played around with variations - always
> leaving in the non-capture group. Then I stumbled on this reference in
> google docs https://support.google.com/a/answer/1371417?hl=en that suggested
> that only RE2 syntax is supported by Google. Following the link to RE2 on
> github and then to the syntax page you will see quite a few formats that are
> not implemented - non-capture group is one of them:
> https://github.com/google/re2/wiki/Syntax.
>
> As soon as I removed the non-capture group like Russ pointed out the code
> worked flawlessly. This worked for me: /SKU\: \*(\d*)/

Can you come up with a simple example where /SKU\: \*(\d*)/ works
but /(?:SKU\: \*)(\d*)/ does not? We use non-capturing groups and they
generally seem to work as expected, but perhaps you've found a bug.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to