I'm having trouble inserting a regular expression into a super-simple Google script for a Sheet/Form. I've checked websites like regex101.com to be sure my syntax isn't a problem with the regex itself, I just can't figure out how to insert it into the Google script.
All I'm doing is trying to rename a "Form Responses" sheet generated by linking a form. I want it to catch any response sheet, so rather than "Form Responses 1," I want to give it a wildcard (if there's a better way to do this than with regex, I'm all ears). The script works just fine if I hard-code "Form Responses 1" as a string, so I don't need any troubleshooting for the rest of the code, just this line:
ss.getSheetByName('Form Responses 1').setName('Entries');
I've tried both /Form Responses .*/ and /^Form Responses/, as well as some of the suggestions I've seen using variables with new RegExp()
, but every attempt results in an error that this field is null
.
Any suggestions would be appreciated, thanks!