if string.match() doesn't match, why is execution of google apps script cancelled?

后端 未结 1 1914
予麋鹿
予麋鹿 2021-01-24 23:46

if I use the following function within Google Sheets it doesn\'t return the value \"not found\". The logs tell me: \"Execution cancelled\".

This happens at the line:

相关标签:
1条回答
  • 2021-01-25 00:20

    Cause:

    The return value of string.match ,

    An Array whose contents depend on the presence or absence of the global (g) flag, or null if no matches are found.

    and

    null !== undefined
    

    So, when it's null, the else statement executes and returns null to sheet. The "execution cancelled" is irrelevant and probably from old logsissue

    Solution:

    Use null to compare return value.

    Snippet:

    if (found === null) { 
    
    0 讨论(0)
提交回复
热议问题