update regex pattern
hi, i’d to update some conditions in my regex pattern.

pattern: “(?<=(total amount|\btotal\b|total due|total amount due)\s+)(zar|r|)[\s-$\d,.]+”

this pattern covers: total amount,total, total due, total amount due

what i don’t want: subtotal - that is working fine

problem i’m facing is: if the t…
you can use the negative lookbehind (?<!sub +) to skip matching "sub " in front of “total”.

(?<=(?<!sub +)(total amount|\btotal\b|total due|total amount due)\s+)(zar|r|)[\s-$\d,.]+

[[image]](https://aws1.discourse-cdn.com/uipath/original/3x/7/7/771d2a72ff53c33207c48813c7b379782be96d4f.png "image")
The existing solutions based on `findall` are fine for non-overlapping matches (and no doubt optimal except maybe for HUGE number of matches), although alternatives such as `sum(1 for m in re.finditer(thepattern, thestring))` (to avoid ever materializing the list when all you care about is the count) are also quite possible. Somewhat idiosyncratic would be using `subn` and ignoring the resulting string...:



```
def countnonoverlappingrematches(pattern, thestring):
  return re.subn(pattern, '', thestring)[1]

```

the only real advantage of this latter idea would come if you only cared to count (say) up to 100 matches; then, `re.subn(pattern, '', thestring, 100)[1]` might be practical (returning 100 whether there are 100 matches, or 1000, or even larger numbers).


Counting **overlapping** matches requires you to write more code, because the built-in functions in question are all focused on NON-overlapping matches. There's also a problem of definition, e.g, with pattern being `'a+'` and thestring being `'aa'`, would you consider this to be just one match, or three (the first `a`, the second one, both of them), or...?


Assuming for example that you want possibly-overlapping matches *starting at distinct spots in the string* (which then would give TWO matches for the example in the previous paragraph):



```
def countoverlappingdistinct(pattern, thestring):
  total = 0
  start = 0
  there = re.compile(pattern)
  while True:
    mo = there.search(thestring, start)
    if mo is None: return total
    total += 1
    start = 1 + mo.start()

```

Note that you do have to compile the pattern into a RE object in this case: function `re.search` does not accept a `start` argument (starting position for the search) the way *method* `search` does, so you'd have to be slicing thestring as you go -- definitely more effort than just having the next search start at the next possible distinct starting point, which is what I'm doing in this function. hello [@scotttpa](/u/scotttpa),

for cumulative totals instead of selecting “all” replace it with “allselected” and also replace the ‘recurring subscriptions’[subscription start date]) with the dates table. so your code should be like this overall -

abcs cumulative started to date =

calculate ( [abc order count … according to python idiomatic, its better to ask for forgiveness (except) then for permission (if). which would make your solution a better fit

however, i disagree with the slicing used in both solutions. you have the index, so its easy to update an element at an index:

the\_list[index] = 'new valu… Check if any of the values in the cells are null.  

If they are you need to modify your code to check for null conditions before using `ToString()`. a pattern with twelve data and twelve greedydata is going to be ridiculously expensive if it fails to match. it may well exceed the 30 second timeout. i would suggest you match multiple patterns to pick out parts of the message

grok {

break\_on\_match => false

match => {

… hi [@nrebhun](/u/nrebhun),

thank you for catching that! to avoid confusion and to add clarity, the provided example should be closes #1. i’ll make sure a push goes up to make the update in the course instructions. you should have three choices.

 thanks for the update...i'll check it out. okay, i think i found out what is happening: <https://github.com/drtimothyaldendavis/suitesparse/issues/45> hi paul,

i believe the financial reporting covers in quite a lot of detail exactly what you are looking for.

from what i can tell you aren’t using templates in your tables…

[[image]](https://forum.enterprisedna.co/uploads/db7134/original/2x/5/559a333f85c159c8d9bec9235ca5c45997d08858.png "image")

if you want to get a certain order and custom table then you really need to use the template approach covered in t… What problem are you facing? Post the error that you get.  

Also please edit your first post by aligning the code properly and wrap [code] tag so that it is easily understandable for us to analyze.