Detecting if an NSString contains…?

后端 未结 7 2085
长情又很酷
长情又很酷 2021-01-30 03:37

How can I detect if a string contains a certain word? For example, I have a string below which reads:

@\"Here is my string.\"

I\'d like to know

相关标签:
7条回答
  • 2021-01-30 04:13

    A complete solution would first scan for the string (without added blanks), then check if the immediately prior character is either blank or beginning of line. Similarly check if the immediately following character is either blank or end of line. If both tests pass then you have a match. Depending on your needs you might also check for ,, ., (), etc.

    An alternative approach, of course, is to parse the string into words and check each word individually.

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