Answers for "python count multiple characters in string"

1

python count multiple characters in string

# Basic syntax:
import re
len(re.findall('[characters]', your_string))

# Example usage:
# say you want to count all G, g, C, or c characters in the following DNA seq
len(re.findall('[GgCc]', "ACGTGCAcgattcgatCGCTAGCTAG"))
--> 14
Posted by: Guest on April-21-2022

Code answers related to "python count multiple characters in string"

Python Answers by Framework

Browse Popular Code Answers by Language