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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:22:24+00:00 2026-05-23T12:22:24+00:00

I am trying to get a regex expression to match a specific url format.

  • 0

I am trying to get a regex expression to match a specific url format. Specifically the api urls for stackexchange. For example I want both of these to match:

http://api.stackoverflow.com/1.1/questions/1234/answers  
http://api.physics.stackexchange.com/1.0/questions/5678/answers

Where

  • everything not in bold must identical.
  • The first bold part, can only be made of a to z, and either one or no full stop.
    • Also it would be good, if there is one full stop the word “stackexchange” must follow. However this isn’t crucial.
  • The second bold part can only be a 1 or a 0.
  • The last bold part can be only numbers 0 to 9, and can be any length
  • There can’t be anything at all before or after the url, not even a trailing slash
  • 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-23T12:22:25+00:00Added an answer on May 23, 2026 at 12:22 pm
    Pattern.compile("^(?i:http://api\\.(?:[a-z]+(?:\\.stackexchange)?)\\.com)/1\\.[01]/questions/[0-9]+/answers\\z")
    

    The ^ makes sure it starts at the start of input, and the \\z makes sure it ends at the end of input. All the dots are escaped so they are literal. The (?i:...) part makes the domain and scheme case-insensitive as per the URL spec. The [01] only matches the characters 0 or 1. The [0-9]+ matches 1 or more Arabic digits. The rest is self explanatory.

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

Sidebar

Related Questions

I'm trying to get a regex that will match: somefile_1.txt somefile_2.txt somefile_{anything}.txt but not
I'm stuck trying to get a regex to match a filetype in a sorting
I'm trying to parse phone number with regex. Exactly I want to get a
I'm trying to create a regex expression to match any string that has exactly
Suppose I was trying to match the following expression using regex.h in C++, and
I'm trying to get all words inside a string using Boost::regex in C++. Here's
I am a bit puzzled with my Regex results (and still trying to get
I am trying to write a regex to get the numbers from strings like
Yep - another noob regex query, which I can't seem to get. I'm trying
I'm trying to get regexp to match some nested tags. (Yes I know I

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.