[ create a new paste ] login | about

Link: http://codepad.org/ru5ZxEY0    [ raw code | fork ]

Python, pasted on Jan 23:
1
2
3
4
5
6
7
8
9
10
11
12
def countSubStringMatch(target,key):
    index_mover = 0
    count = 0
    while index_mover < len(target):
        instance = str.find(target, key, index_mover)
        if instance >= 0:
            count += 1
            index_mover = instance + len(key)
        else:
            break
        
    return 'The number of instances of ' + key + ' in ' + target + ' is ' + str(count)


Output:
No errors or program output.


Create a new paste based on this one


Comments: