Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #This is my long string object I would like to count all substring in:
- >>>type(contents2)
- <class 'str'>
- #This is my regular expression substring I want to count the instances of, any size lengths of N's
- >>>import re
- >>> nstring = re.compile(r"[^N][N+][^N]")
- #Search through the string and count the number of times the substring appears
- >>>len(re.findall(nstring, contents2))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement