Best way to find a substring in a string

后端 未结 7 1354
北荒
北荒 2020-12-11 16:32

I have a problem where I am trying to search for a substring in string. That substring may or may not be in the string.

str = \"hello how are you?\"
substr =         


        
7条回答
  •  爱一瞬间的悲伤
    2020-12-11 17:04

    If you're convinced that the facilities in your runtime system (which offer string-in-string search and the like) are not fast enough for your application, try implementing the KMP algorithm.

    But, the implementers of modern runtime systems probably have already done this for you.

提交回复
热议问题