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

Question

Question

how to take negative value in Laserfiche pattern matching

asked on October 11, 2019

hi 

we have negative currency amount for few of the invoices. 

 

Like -$181.00

 

We are using the below regex for pattern matching but it is not taking the negative value.

(\d*[,]*\d+\.\d{2}[\-]*)|No.+\$(.00)

if we want to take negative value if the invoice charge is negative then how we can do that?

0 0

Answer

SELECTED ANSWER
replied on October 14, 2019

This should take care of that:

(?:Balance[\W\w]*Balance\W*\s)([\$-]+\d*[,]*\d+\.\d{2})(?:\s*Heating)

 

The other regular expression grabbed the value after the last iteration of the word 'Balance' in the entire input, whereas the above will grab the value following the last iteration of the word 'Balance' BEFORE the word 'Heating', which should be the value you're looking for here.

0 0

Replies

replied on October 11, 2019 Show version history

Try adjusting your regular expression to the following:

([\$-]+\d*[,]*\d+\.\d{2})

 

With that, you don't need the "No." parameter in there; it will look for any number that begins with either symbol ( - or $ ), or both, and ends with a decimal followed by 2 numbers.

0 0
replied on October 11, 2019

Thanks Dustin it worked. 

 

We are facing another issue.  we are trying to capture date but for some cases after the date it is having some special character. how we can remove the special character.

current patter: Amount\s*Due\s*By\s*(\d{2}/\d{2}/\d{4})

example  Amount Due by- 10/01/2019$

or 09/20/2019 

 

0 0
replied on October 11, 2019

The special character after the date wouldn't affect that regular expression, however any special character BEFORE the date (between "By" and the date) would cause the date not to be grabbed (i.e. "Amount Due By:" or "Amount Due By -" etc.). Use the following regular expression:

Amount\s*Due\s*By\W*(\d{1,2}/\d{1,2}/\d{2,4})

 

This would grab any date after the phrase "Amount Due By" regardless of if there are or are not special characters following "By"; I've also adjusted the parameters in the date digits so it will grab dates with 1 or 2 digits month/day and 2 or 4 digit year (ex: 9/9/19, 9/9/2019, 09/09/19, 09/09/2019 will all work).

1 0
replied on October 11, 2019

Thanks...

 

Is there a way we can take the 2nd matching value in pattern matching.

like: Previous balance *****

Balance ****

we want to take the balance value. and we are using Balance\s*\$\s*(\d*[,]*\d+\.\d{2}[\-]*)

0 0
replied on October 11, 2019

To clarify...

You have a zone that grabs the following output:

Previous Balance $100.00

Balance $200.00

...and you want to grab the second value (for 'Balance') and not the first value (for 'Previous Balance'). Is that correct?

0 0
replied on October 11, 2019

yes

0 0
replied on October 11, 2019

Is there anything else grabbed in that zone, other than those 2 lines?

In other words, are you scrubbing the whole page and trying to pull that second value, or is the above an accurate depiction of everything that is initially grabbed in that zone for scrubbing?

1 0
replied on October 11, 2019

it is like below:

 

 Previous Balance                                    $350.29     Billing Days         31       31      31
     08/14/2019  Payment                                           -$115.10     Avg Temp        73°F     77°F    76°F
          Balance                                         $235.19     Heating Deg Days   

0 0
replied on October 11, 2019

This should do it:

(:?Balance[\W\w]*Balance\W*\s)([\$-]+\d*[,]*\d+\.\d{2})

 

This will grab the value following the second time it sees the word 'Balance' in the capture, followed be either symbol ( - or $ ), or both, and a number ending in a decimal with 2 digits.

 

Try it out, and let me know if you have any other questions. Be sure to mark the initial response as the answer to your first question.

0 0
replied on October 11, 2019

Hi Datsun, 

above solution is not working. it is giving the whole input. 

just to give you more info, below the input value:

 

   09/04/2019  Previous Balance                                    $214.39     Billing Days         30       31      30
      10/04/2019  Payment                                           -$214.39     Avg Temp        69°F     73°F    69°F
           Balance                                           $0.00     Heating Deg Days       12    0      46
           Total Current Charges                                   $208.73     Cooling Deg Days      135      241     177
           Total Current Balance                                   $208.73     Therms Used          650    688.5   700.3 
 
 

0 0
replied on October 11, 2019 Show version history

Sorry, I got the : and ? backwards in the beginning. This should be it:

(?:Balance[\W\w]*Balance\W*\s)([\$-]+\d*[,]*\d+\.\d{2})

 

...or you could take the beginning out of the non-capture group "(?: )", and use it like this:

Balance[\W\w]*Balance\W*\s([\$-]+\d*[,]*\d+\.\d{2})

1 0
replied on October 12, 2019

Thanks it worked :)

0 0
replied on October 14, 2019

We are facing some issue. if the text is like below the patter is taking 151.33 we want to capture the balance

 

Activity Since Last Bill                                                         2019     2019    2018
       08/07/2019  Previous Balance                                    $152.43     Billing Days         31       31      31
       08/23/2019  Payment                                           -$152.43     Avg Temp        73°F     77°F    76°F
            Balance                                           $0.00     Heating Deg Days        0    0       0
            Total Current Charges                                   $151.33     Cooling Deg Days      241      379     342
            Total Current Balance                                   $151.33     Therms Used        449.3    502.3   458.2

0 0
replied on October 14, 2019

That's what is should be capturing, the 'Total Current Balance' is $151.33. The 'Total Current Charges' and 'Total Current Balance' are the same in the above text, but it's grabbing the value from the 'Total Current Balance'. Is that not what you want to grab from there?

0 0
replied on October 14, 2019

actually we want to capture Balance . which is 0.00

0 0
SELECTED ANSWER
replied on October 14, 2019

This should take care of that:

(?:Balance[\W\w]*Balance\W*\s)([\$-]+\d*[,]*\d+\.\d{2})(?:\s*Heating)

 

The other regular expression grabbed the value after the last iteration of the word 'Balance' in the entire input, whereas the above will grab the value following the last iteration of the word 'Balance' BEFORE the word 'Heating', which should be the value you're looking for here.

0 0
replied on October 14, 2019

thank you for the help

0 0
replied on October 11, 2019

The special character after the date wouldn't affect that regular expression, however any special character BEFORE the date (between "By" and the date) would cause the date not to be grabbed (i.e. "Amount Due By:" or "Amount Due By -" etc.). Use the following regular expression:

Amount\s*Due\s*By\W*(\d{1,2}/\d{1,2}/\d{2,4})

 

This would grab any date after the phrase "Amount Due By" regardless of if there are or are not special characters following "By"; I've also adjusted the parameters in the date digits so it will grab dates with 1 or 2 digits month/day and 2 or 4 digit year (ex: 9/9/19, 9/9/2019, 09/09/19, 09/09/2019 will all work).

You are not allowed to follow up in this post.

Sign in to reply to this post.