Mar-29-2022, 09:12 AM
Example of using re
import re mystring = 'Peter Piper peppers picked a peck of pickled peppers. Where\'s peppers the peck of dozens of pickled peppers Peter Piper picked?' findit = re.search(r'peck(.*?)peppers', mystring).group(1) print(f'One occurance -> {findit}') findit = re.findall(r'(?:peck)(.*?)(?:peppers)', mystring) print(f'Multiple occurances - > {findit}')
Output:One occurance -> of pickled
Multiple occurances - > [' of pickled ', ' of dozens of pickled ']
I welcome all feedback.
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags
Download my project scripts
The only dumb question, is one that doesn't get asked.
My Github
How to post code using bbtags
Download my project scripts