Sign in to follow this  
Followers 0
Newb

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

1 post in this topic

#1 ·  Posted (edited)

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.

Share this post


Link to post
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
Sign in to follow this  
Followers 0