Hi, I'm trying to extract a payment amount. I'm in QF. Can someone see what I'm doing wrong?
Question
Question
Answer
Changing it to this should let it capture commas:
PAYMENT AMOUNT\s*([\d,]*\.\d{2})
Basically, instead of allowing only digits before the period, any character in the class "digit or comma" is allowed. Not that this is too relaxed for validation: e.g., "1,,1,2.01" would be considered valid, but should be just fine for data extraction.
Also, the original regex should have had a \ before the period to indicate you wanted a literal period, not "any character".
Replies
Hi Carlos,
Not a regex expert here, but try changing your \s to \s*
That should allow for any amount of whitespace, rather than whatever Quick Fields determines is "1 whitespace," which might be what your pattern is looking for.
In addition to what Jacob said above, you need parentheses around the data you want to extract.
Yessssss they both worked. the \s* and parentheses!!!!! Thanks a million!!!
Hi all, after using this expression PAYMENT AMOUNT\s*(\d*.\d{2}) I've noticed the anything in this format 5623125.02 without the comma will work. However, there are times when I see some without commas and some with commas.
will work= 5623125.02
will not work = 562,3125.02
Not sure what I'm missing in this PAYMENT AMOUNT\s*(\d*.\d{2}) to have both version above work.
Changing it to this should let it capture commas:
PAYMENT AMOUNT\s*([\d,]*\.\d{2})
Basically, instead of allowing only digits before the period, any character in the class "digit or comma" is allowed. Not that this is too relaxed for validation: e.g., "1,,1,2.01" would be considered valid, but should be just fine for data extraction.
Also, the original regex should have had a \ before the period to indicate you wanted a literal period, not "any character".
There is a website that lets you test these expression. By chance you have that link?
There are many, but make sure you're using a .NET regular expression engine or site specifically for .NET regular expressions.
Here are two:
- http://regexstorm.net/tester
- https://regex101.com/ (make sure to select .NET (C#) in the left pane under "Flavor")