Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7518279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T01:43:44+00:00 2026-05-30T01:43:44+00:00

update I have a regular expression inside a resource file, it is rendered through

  • 0

update

I have a regular expression inside a resource file, it is rendered through a @Action method which takes all resource strings and outputs a script with them:

@model IEnumerable<LocalizationModel>
; (function (window) {
    var l = {
    @foreach(LocalizationModel file in Model)
    {
        @:@file.Title: {
        foreach(var entry in file.Items)
        {
            @:@entry.Key: @Html.Raw(@HttpUtility.JavaScriptStringEncode(entry.Value.ToString(), true)),
        }
        @:},
    }
    };

    // expose the l object to the global namespace.
    window._l = l;
})(window);

This partial is in turn minified:

    [HttpGet]
    public ContentResult Localization()
    {
        CultureInfo culture = CultureInfo.InvariantCulture; // easily replaceable by user culture.
        IEnumerable<LocalizationModel> model = GetLocalizationModel(culture);

        const string viewPath = "Localization";
        string view = RenderPartialToString(viewPath, model);
        string minified = JavaScriptCompressor.Compress(view, false);

        return new ContentResult
        {
            Content = minified,
            ContentEncoding = Encoding.UTF8,
            ContentType = Constants.JavaScriptContentType
        };
    }

This produces a result similar to this (beautified):

(function (b) {
    var a = {
        Common: {
            Errors: "Errores",
            SingleError: "Error",
        },
        Regex: {
            WebLink: '(?i)\\b((?:https?://|www\\d{0,3}[.]|[a-z0-9.\\-]+[.][a-z]{2,4}/)(?:[^\\s()\u003c\u003e]+|\\(([^\\s()\u003c\u003e]+|(\\([^\\s()\u003c\u003e]+\\)))*\\))+(?:\\(([^\\s()\u003c\u003e]+|(\\([^\\s()\u003c\u003e]+\\)))*\\)|[^\\s`!()\\[\\]{};:\u0027".,\u003c\u003e?«»“”‘’]))',
            Link: '(?i)\\b((?:[a-z][\\w-]+:(?:/{1,3}|[a-z0-9%])|www\\d{0,3}[.]|[a-z0-9.\\-]+[.][a-z]{2,4}/)(?:[^\\s()\u003c\u003e]+|\\(([^\\s()\u003c\u003e]+|(\\([^\\s()\u003c\u003e]+\\)))*\\))+(?:\\(([^\\s()\u003c\u003e]+|(\\([^\\s()\u003c\u003e]+\\)))*\\)|[^\\s`!()\\[\\]{};:\u0027".,\u003c\u003e?«»“”‘’]))',
        },
    };
    b._l = a })(window);

Then, somewhere, I do:

var pattern = new RegExp(_l.Regex.WebLink);
console.log(pattern.test(input.val()));

But I get an “invalid quantifier” error when creating the RegExp.

What is wrong?
I’m now thinking the unicode characters might be the breaking difference here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T01:43:45+00:00Added an answer on May 30, 2026 at 1:43 am

    Not sure what _l.Regex.Link and _l.Regex.WebLink are, but you’re testing for a regex pattern that’s literally “_l.Regex.Link”, not the variable. If they are already RegExp objects, just remove the /s, if they’re strings create the RegExp objects first:

    var pattern = new RegExp( _l.Regex.Link );
    console.log( pattern.test( p ) );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a text file which needs to be constantly updated (regular intervals). All
have the following text file: <div> <asp:HyperLinkField HeaderText=Hello World of Regular Expression /> </div>
I have several update methods in a javascript file, used for updating my ajax
I have a regular expression that throws ORA-12733, regular expression is too long. How
In Rubular, I have created a regular expression: (Prerequisite|Recommended): (\w|-| )* It matches the
I'm writing a regular expression to match data from the IMDb soundtracks data file.
I have the following regular expression validator to detect whether an input string contains
I have created my own XML-file on my Android phone, which looks similar to
Apache documentation states that CondPattern is the condition pattern, a regular expression which is
I have a Rails model with an attribute that is a regular expression. Is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.