Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

python get pattern from string

Get occurrence of substring in string 

def count_substring(string, sub_string):
    
    mycount = 0
    result = 0
    for x in string:
        if x == sub_string[0]:
            if sub_string == string[mycount:len(sub_string)+mycount]:
                result = result + 1
        mycount = mycount + 1    
    return result
 
PREVIOUS NEXT
Tagged: #python #pattern #string
ADD COMMENT
Topic
Name
6+4 =