-1
Text=str(self.Text).split("46539 Dinslaken")[0]
Street=re.findall(r"(?s:)"+self.street_pattern,StreetText)

#I tried to count the matches that were found here:
StreetItems=len(Street)

#Here I wanted to get the last item of the matched items
Street=Street[StreetItems-1]

I just get a list with alot of items back

Has anybody an advice?

Barmar
  • 669,327
  • 51
  • 454
  • 560
  • 2
    FYI you can get the last element of a list with `[-1]`. Negative indexes count from the end. – Barmar Jun 01 '22 at 15:37
  • What is `self.street_pattern`? If it contains capture groups, each element of `Street` is a list of all the captured strings, not the whole match. – Barmar Jun 01 '22 at 15:37
  • Either use non-capturing groups, or use `re.finditer()` and explicitly extract `.groups(0)` from each of the results. – Barmar Jun 01 '22 at 15:41

0 Answers0