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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:35:40+00:00 2026-05-17T15:35:40+00:00

I need to extract a value from a large body of text. I’m assuming

  • 0

I need to extract a value from a large body of text. I’m assuming the best way to do this would be to use a regular expression. If anyone thinks there’s a better way to do it, feel free to offer up a suggestion.

The value I need to extract always appears in a string of the form:

[formatted_int_value] results across [the_integer_value_I_need_to_extract] pages

e.g: 3,342 results across 67 pages

In the example above the value I’m trying to extract is 67. Also note that each word in the example above may be separated by one or more whitespaces and/or newline characters. And, as mentioned above, this text is part of a larger body of text (I’m screen scraping a web page).

Can someone help me with a regex to extract the int value I need (67 in my example above) that takes into consideration the conditions I’ve provided?

Thanks.

  • 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-17T15:35:40+00:00Added an answer on May 17, 2026 at 3:35 pm

    The regex would be quite straight-forward:

    ([\d,]+)\s+results\s+across\s+(\d+)\s+pages
    

    The 67 would be in group 2, the other number (if you need it) in group 1.

    var text = "some text here 3,342 results across 67 pages some more text here";
    var regex = /([\d,]+)\s+results\s+across\s+(\d+)\s+pages/;
    
    var matches = regex.exec(text);
    
    /* matches will be this array:
    
    ["3,342 results across 67 pages", "3,342", "67"]
    ---- entire match --------------  --g1---  -g2-    
    */
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i need to extract the numbers alone from this text i use sub string
I have a large String and I need to extract String value from it.
I need to match this and extract the value from these tags. Problem is
I need to extract a value from a hidden HTML field, have somewhat figured
I need to extract this text: Line 1 text. Line 2 text. Line 2
I need to extract a value from a process array to myArray: File: MyClass.vb
I managed to extract a value from a XML file: <--more labels up this
On a day-to-day basis I need to extract bits of text from logs and
I have a situation where I need to extract a value from a form
For example: http://foobar.com/foo/bar/foobar.php From this address, I need to extract the following: http://foobar.com/foo/bar 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.