Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Find all of the instances of non alphanumeric characters in 'lorem_ipsum'
- #Output the number of non-alphanumeric characters.
- results= re.findall(r'[^a-zA-Z0-9]',lorem_ipsum)
- print(len(results))
- #Find all of the instances of 'sit-amet' or 'sit:amet' characters in 'lorem_ipsum'
- #Set variable named 'occurrance_sit_amet'
- #Output the number of sit-amet or sit:amet occurrances.
- occurrences_sit_amet= re.findall(r'sit[-:]amet',lorem_ipsum)
- print(len(occurrences_sit_amet))
- #Replace sit:amet and sit-amet with sit amet using.
- #Set variable named 'replace_results'
- replace_results = re.sub('sit[:-]amet','sit amet', lorem_ipsum )
- #Find all of the instances of 'sit amet' in 'replace_results'
- #Set a variable named 'occurrance_sit_amet'
- #Output the number of sit amet occurrances.
- occurrences_sit_amet= re.findall('sit amet',replace_results)
- print(len(occurrences_sit_amet))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement