Search code examples
regexamplifyjs

Regular expression Syntax error - AmplifyJS


I just added "amplify.js" to my ASP.NET MVC3 project and getting Regular expression syntax error for this line :

key = key.replace( /[^-._0-9A-Za-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u37f-\u1fff\u200c-\u200d\u203f\u2040\u2070-\u218f]/g, "-" );

Does anyone have any idea what is wrong with this reg-ex?

Thanks for you helps


Solution

  • https://github.com/appendto/amplify/issues/65

    Unicode character \u37f is incorrect an should be corrected as \u037f

    key = key.replace( /[^-._0-9A-Za-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u37f-\u1fff\u200c-\u200d\u203f\u2040\u2070-\u218f]/g, "-" );
    

    should be

    key = key.replace( /[^-._0-9A-Za-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u037f-\u1fff\u200c-\u200d\u203f\u2040\u2070-\u218f]/g, "-" );