and here using %z (really deprecated?) or \000 would be incorrect: you don't want to match a nul character in the source text (which would be invalid anyway anywhere in a _javascript_ source, or URL, or HTML using a single-byte character encoding). To match the end of string use the '$' anchor only.
Yes Lua can contain nul bytes (it is "agnostic" about the text encoding and character set used, a Lua string could as well contain UTF-16 or UTF-32, with MANY null bytes, but usually it will be used with UTF-8 or a 7-bit or 8-bit encoding like US-ASCII, ISO-8859-9-*, or a Windows codepage like Win1252, which has almost deprecated ISO-8859-1 in HTML5 where US-ASCII and ISO-8859-1 are changed to compatiblity aliases for Win1252, allowing its encoded graphic characters instead of C1 controls that are almost deprecated but were reserved in ISO-8859-* and interpretation of non-7bit characters as G1 characters of ISO8859; nobody seems to use C1 controls today, and as well 7-bit only charsets are deprecated in HTML, with its many national variants in ISO646; however other 8-bit charsets are still widely used, notably for Cyrillic, Arabic, Thai, and multibyte charsets of East Asia). If you need to handle and covert legacy data (including from various public databases or old interfaces, or legacy filesystems like FAT or MacOS without their UTF-16 extensions, or old FTP sites, or some old telnet, or to handle emails and MIME, or some old *.dbf files, you still need some of these charsets, but Lua natively embeds no support for these conversions in its strings support, you have to include a conversion library in your project.