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

  • SEARCH
  • Home
  • 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 819507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T02:19:16+00:00 2026-05-15T02:19:16+00:00

What Regex do I need for match this url: Match: 1234 1234/ 1234/article-name Don’t

  • 0

What Regex do I need for match this url:

Match:

1234
1234/
1234/article-name

Don’t match:

1234absd
1234absd/article-name
1234/article.aspx
1234/any.dot.in.the.url
  • 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-15T02:19:17+00:00Added an answer on May 15, 2026 at 2:19 am

    You can try:

    ^\d+(?:\/[\w-]*)?$
    

    This matches a non-empty sequence of digits at the beginning of the string, followed by an optional suffix of a / and a (possibly empty) sequence of word characters (letters, digits, underscore) and a -.

    This matches (see on rubular):

    1234
    1234/
    1234/article-name
    42/section_13
    

    But not:

    1234absd
    1234absd/article-name
    1234/article.aspx
    1234/any.dot.in.the.url
    007/james/bond
    

    No parenthesis regex

    You shouldn’t need to do this, but if you can’t use parenthesis at all, you can always expand to alternation:

    ^\d+$|^\d+\/$|^\d+\/[\w-]*$
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm facing a problem with Regex... I had to match sharepoint URL.. I need
Here's what I need- RegEx to match a url pattern and rewrite it to
I need to match any number that comes after /page/ in a URL. Example
I need to match Safari browsers, but not Chrome browsers using one Regex. I
I need a regex that will match blahfooblah but not blahfoobarblah I want it
I need some help. I am looking for a regex that would match the
string content= <br /><br /><a href=need to replace this url>Cooking School</a><br /><br /><a href=http://www.sdlm.com>Feed
I'm trying to create a snippet of regex that will match a URL route.
I have a regex I need to match against a path like so: C:\Documents
I need to match and replace some comments. for example: $test = the url

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.