Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #python #count #multiple #characters #string
ADD COMMENT
Topic
Name
4+1 =