In this example, it is important to write 'o' before '+', because this metacharacter checks if there is a preceding character present (there must be one of the repeating characters to check!). However, you could avoid this by using the asterisk ('*') metacharacter.
This matches the string perfectly without having to know about the preceding character beforehand.
xxxxxxxxxx12
// Adding a function to wrap the existing codefunction findMatch() { let s = 'Zoooooootopia'; if (/Z*topia/.test(s)) { console.log("Found a match!"); } else { console.log("Did not find a match."); }}// Driver code to execute the functionfindMatch();OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment



