javascript - RegExp range out of order with complex pattern -
this pattern:
var pattern = "/(?:https?:\/\/)?(?:www\.)?facebook\.com\/(?:(?:\w)*#!\/)?(?:pages\/)?(?:[\w\-]*\/)*([\w\-\.]*)/"; var matches = $("#search input").val().match(new regexp(pattern));
when use it, gives me error:
uncaught syntaxerror: invalid regular expression: //(?:https?://)?(?:www.)?facebook.com/(?:(?:w)*#!/)?(?:pages/)?(?:[w-]*/)*([w-.]*)//: range out of order in character class
from reading on similar issues came attention need double escape characters, don't know out of pattern.
remove unwanted double quotes regex pattern:
var pattern = /(?:https?:\/\/)?(?:www\.)?facebook\.com\/(?:(?:\w)*#!\/)?(?:pages\/)?(?:[\w\-]*\/)*([\w\-\.]*)/;
Comments
Post a Comment