On 1/18/2016 14:05, Charles T. Smith wrote:
On Fri, 15 Jan 2016 14:20:17 +0100, Wolfgang Maier wrote:

pattern = pattern_str.compile()
try:
      matches = pattern.findall(some_str, endpos=some_str.index(tail))
except ValueError:
      # do something if tail is not found
      pass

Oh!  I think that's it!


matches = findall (pattern, string)
for file in matches:
     use (file)

Totally cool!  Thank you.


Great if it helps you. Just beware that this simplified version is not exactly equivalent to your initial perl snippet:

Generally, findall will find ALL occurrences of pattern, not just adjacent ones.

Since your perl example would never terminate if something non-matching is interleaved with pattern matches I figured you never expect that case.

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus


--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to