Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regex Number with or wothout thousands separator

Status
Not open for further replies.

stevio

Vendor
Jul 24, 2002
78
AU
Hi all,

Have a number which can be a 1 or more digits. Max number has thousands separator

Trying to work out a regex to match any of these:
Code:
'345' -match '(\d{1,})' 
"Number is $($matches[1])"
Works for single digit and 3 digit numbers

and

Code:
'3,345' -match '(\d{1}\,\d{1,3})'

works for 4 digit numbers, but I can't get a single regex to find all three numbers

Is there an easy way to do this?

Example numbers

3

456

3,345
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top