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 7579051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:34:47+00:00 2026-05-30T17:34:47+00:00

I have this regular expression to validate the URL: ^[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/\S*)?$^ . This regular expression

  • 0

I have this regular expression to validate the URL: ^[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(/\S*)?$^. This regular expression works smoothly but I want to add a limit the amount of W’s in the beginning of the URL.

If the user tries to save the URL with under 3 W’s (for example ww), the regular expression will deny the save. The same result will also happens if the user tries to save the URL with more than 3 W’s (for example wwww).

How can I solve this problem?

Thanks in advance.

  • 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-30T17:34:48+00:00Added an answer on May 30, 2026 at 5:34 pm

    This sort of filtering is not a good fit for regular expressions, I think.

    The problem is that the rules for what should be a “match” are actually pretty complicated. Essentially the rules are this:

    Match something if it has :

    • start of text
    • either:
      • exactly three w characters followed by a dot OR
      • any alphanumeric characters or dots repeated any number of times, followed by a dot
        • unless all of those characters are w characters, but the number of characters is not equal to three (plus the dot)
    • two or three more alphanumeric characters
    • end of text

    The unless all of those characters are w characters… part is the tricky part. Regex isn’t really well suited to this task.


    For “historical” purposes:

    Use {n} to repeat part of the expression n times.

    ^w{3}\.[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?$
    

    Use ? to make part of the expression optional.

    The parentheses are a grouping operator. The “w times three” and dot are moved inside the group, and the group is made optional with the ? operator.

    ^Guess what? this doesn't work.$
    ^I tried to delete the answer but I can't until you unaccept it.$
    

    I also escaped the last forward slash with a backslash in these examples, since regular expressions are often delimited with / characters. You can remove it if you don’t need it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently I have this regular expression to validate letters, dash and spaces. /^[a-zA-Z-\s]*$/ Now,
I have a numberDecimal EditText which I want to validate using a regular expression.
I have this regular expression to help me validate a form input. var nrExp
I am using this regular expression to validate youtube urls. ^http:\/\/(?:www\.)?youtube.com\/watch\?(?=.*v=\w+)(?:\S+)?$ it works great.
I have this regular expression below to validate a security question where some one
I have this regular expression: ^\$?(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$ however it is failing when i have an
I have this Regular Expression that matches the following strings: <!-- 09-02-2009 ---> <!--
I have a regular expression like this (much simplified): ^(ab)*$ And am matching against
Is a regular expression the correct way of going about this? I have a
I am using the following regular expression to validate e-mails, but it allows empty

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.