nodejs check if string matches regex
// Define a regular expression pattern
const regexPattern = /^[a-zA-Z0-9]+$/;
// Sample string to be checked
const inputString = "example123";
// Use the test method of the RegExp object to check if the string matches the pattern
const isMatch = regexPattern.test(inputString);
// Log the result
console.log(isMatch);