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

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -