You are viewing limited content. For full access, please sign in.

Question

Question

Pattern Matching Amount

asked on June 19, 2015

I have an amount that is in a text file and I'm trying to use PM to capture that amount.  I'm using the following:

 

\d*\S?\d+\S?\d*.\d\d

 

However, it also is capturing 103.12111. etc

 

The amount is listed as the following:  x,xxx,xxx.xx (can be less as well).

 

 

0 0

Answer

SELECTED ANSWER
replied on June 19, 2015

([0-9,]{0,3})(?:\s?)([0-9,]{0,3})(?:\s?)([0-9,]{0,3})(?:\s?)([0-9,]{0,3})(?:\s?)([0-9,]{0,3})(?:\s?)(\.\d\d)

 

I think there's a better way but this would catch and remove the spaces.

2 0
replied on July 22, 2015

This worked for me, also, but I had to add another set of (?:\s?) because I was getting a space before and after the decimal point!

Thanks!

Connie Prendergast, Flagstaff County

0 0

Replies

replied on June 19, 2015

So you only want to return the decimal point, the two digits after it, and all of the digits and commas before it?  Could you use something like this:

 

[0-9,]+\.\d\d

 

So it would grab every number and comma leading up to the decimal point, and then the next 2 numbers.

0 0
replied on June 19, 2015

Try

 

\d{1,3}[,]?\d{1,3}[,]?\d{1,3}[.]\d{2}\Z

replied on June 19, 2015

That works, but how do I remove white spaces?  So I was able to capture the above, but it captured like this: 99, 999, 999.99 when what I need is 99,999,999.99

 

 

 

 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.