Jump to content

[SOLVED] Telling regexp to not catch a string if it's longer then X


Recommended Posts

I need a string who catches numbers up to 999,999,999 (with commas)

this is what i came up with

[^,0\d\S][1-9]{1,3}(?:,[^\d]?\d{3}){1,2}

but for example if i take the number 333,444,555,666,777,888

it just cuts it as 333,444,555 still taking it as valid.

This is one try to avoid it, but i don't know how to link it to the previous part of the regex

[^,0\d][1-9]{1,3}(?:,[^\d]?\d{3}){1,2}(?:,[^\d]?[^\d]{3}){3,}

(the thing is: take numbers make with 3 numbers, a comma, and other 3 numbers and a comma for a max of 2 times, but not take them if the part after the first 3 numbers (millions units) and the comma contains more than 2 times

333,444,555,666,777,888

Anyone can help me on how to link the first part to the second or with it's own solution?

SORRY FOR WASTING SPACE, Casually found the solution with an help of Jos. Thanks anyway.

Edited by Newb

I'm a compulsive poster. When I post something, come to read it at least 5 minutes later after the posting, because I will edit it. I edited even this signature a few minutes later after I wrote it.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...