Best way to find a substring in a string

后端 未结 7 1320
北荒
北荒 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:11

    For an overview of "other ways", you can start with the "String-searching algorithm" article on Wikipedia.

    Indexing strings using "Substring index" is one very obvious way of speeding things up, as mentioned by Martin, which only is appropriate if you are doing several searches over the same string:

    0 讨论(0)
提交回复
热议问题