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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:16:56+00:00 2026-06-15T06:16:56+00:00

I need to match any number that comes after /page/ in a URL. Example

  • 0

I need to match any number that comes after /page/ in a URL.

Example URL:

http://example.com/something/page/2/

What i want out of it:

2

I wrote this, but for some reason i’m getting NULL.

/page/(\d)

Am i missing something? The regex i wrote works when testing it on this site, but i can’t get it to work in js.

When i run this:

console.log(url);
var mr =  url.match('/page/(\d)');
console.log(mr);

I get:

http://example.com/something/page/2/ theme.js:32
null 

Any ideas?

  • 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-06-15T06:16:57+00:00Added an answer on June 15, 2026 at 6:16 am

    You may use

    var nb = url.match(/\/page\/(\d)/)[1];
    

    When you have a / in a regexp, it needs to be escaped.

    Note that I prefer to use the /someregexp/ notation, as a literal regexp doesn’t need to be computed each time it is used.

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

Sidebar

Related Questions

I need to match a image url like this: http://site.com/site.com/files/images/img (5).jpg Something like this
What's the shortest regex that can match non-zero floating point numbers with any number
I need a regular expression to match any number from 0 to 99. Leading
I need to match with preg_match the urls of a certain domain that end
I need to match abreviations, where a dot means everything that starts with, like:
Hi I need to create a regular Expression that will match the following pattern:
I need a regex pattern (must be a single pattern) to match any text
I have a credit card number that I need to check if it has
I need to retrieve records that match IDs stored in a list. The query,
I need to match complete dynamic URL to set-up as a goal in Google

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.