Find all the occurrences of a character in a string

后端 未结 7 598
情深已故
情深已故 2020-12-01 12:02

I am trying to find all the occurences of \"|\" in a string.

def findSectionOffsets(text):
    startingPos = 0
    endPos = len(text)

    for position in te         


        
7条回答
  •  再見小時候
    2020-12-01 12:28

    import re
    def findSectionOffsets(text)
        for i,m in enumerate(re.finditer('\|',text)) :
            print i, m.start(), m.end()
    

提交回复
热议问题