Best way to find a substring in a string

后端 未结 7 1388
北荒
北荒 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 16:57

    If you want only check if a substring is in string, you can use: str[substr].

    It returns substring or nil.

提交回复
热议问题