My question has previously been closed because it's apparently a duplicate of this one -- however, I don't want to replace anything, I want to see if specific strings match a general template.
I basically have dynamically generated strings containing ever-changing substrings made up of 11 random characters. E.g.:
"This is an example string: 5ju6hmama7l"
"This is an example string: 4nlc9jhm1ub"
"This is an example string: 5elk0k04nq9"
etc.
I want to write code which verifies whether the dynamically generated string matches this general pattern, without having to specify the ever-changing substring. What I've tried so far:
const reg = /([a-z0-9]{10})\w/
const templateString = `This is an example string: ${reg}`
const actualString = "This is an example string: 5ju6hmama7l"
console.log(templateString.test(actualString))
console.log(templateString.match(actualString))
console.log(templateString.includes(actualString))
etc., but this hasn't worked. I'm sure there's an easy way to match the template string against the actual dynamically generated one, but I can't figure it out.