I’ve never been good with regex syntax, can someone help me out to to check if a URL matches a specific structure in my example?
The .* can be anything including /-_# etc, the 0-9 would be any number length (ex 1993334).
var pattern = new RegExp('/articles/[0-9]/[.*]');
if (pattern.test(document.location.href)) {
// match found
}
Try this:
So, escape the slashes, and use
+to specify there has to be “one or more” of the preceding element.