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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:24:27+00:00 2026-06-06T19:24:27+00:00

In particular, is this possible with Javascript? >> Version 1.2.3.4.match(/\S+ (\d+)(\.\d+)*/) [Version 1.2.3.4, 1,

  • 0

In particular, is this possible with Javascript?

>> "Version 1.2.3.4".match(/\S+ (\d+)(\.\d+)*/)
["Version 1.2.3.4", "1", ".4"]

It’s obvious $2 gets set to the last Kleene-“match”. Is there no built-in method to retrieve the rest (".2", ".3")?

If this cannot be done easily in JS, could Perl do it?

UPDATE: Many of the answers so far have been “workarounds” which work because of the simplicity of my example. If the part that repeated that I wanted to match was more than just a number, they wouldn’t work.

However, a very valid solution does exist: use /expr/g global regex matching: just filter out the parts that repeat and use that. I find this to be somewhat less flexible than the more generally applicable * operator but it will obviously get the job done in most cases.

  • 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-06T19:24:28+00:00Added an answer on June 6, 2026 at 7:24 pm

    Regex in JavaScript, like most other regex flavors, only captures the last value of the capturing group if it is matched repeatedly. The only well known regex lib (that I know of) where you get access to all of the previous matched captures is the one in .NET.

    So no, you can’t do this in JS.

    In Perl there are a couple of ways you can accomplish such things. One of the more elegant is probably to use \G (which works in PCRE too).

    For example:

    "Version 1.2.3.4" =~ /(?:\S+ |\G(?!^)\.)(\d+)/g
    

    Returns (in list context):

    (1, 2, 3, 4)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In this particular code sample I want to reference the second overloaded method (int
Cascading deletes aren't setup on this particular database. Just wondering if there's a way
is it possible to use javascript to reload a particular image that is has
Is it possible that some javascript or jquery can handle this: I have an
I've built this website last week, which has worked perfectly across all browsers that
Bjarne suggests using the condition in if's as scope restriction. In particular this example.
Apologize if this particular problem has been answered already (a search didn't turn anything
I know this particular query works, as I tested it with unprepared, procedural methods.
I seem to be getting this particular always when i am trying to receive
I get the StackOverflow error running this particular code: litera.addTextChangedListener(new TextWatcher(){ public void afterTextChanged(Editable

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.