【问题标题】:Case sensitive string replacement Objective C [closed]区分大小写的字符串替换目标 C [关闭]
【发布时间】:2013-09-11 11:43:53
【问题描述】:

我需要从区分大小写的字符串中替换子字符串。例如在以下字符串中:

replace the String with a string

我需要将单词String 替换为大写Ssentence,但另一个string 必须不受影响。我能做些什么来实现这一目标?我试过stringByReplacingOccurrencesOfString,但它不区分大小写。

【问题讨论】:

  • 叹息!请阅读 NSString 的规范。

标签: objective-c replace nsstring


【解决方案1】:

你可以使用

stringByReplacingOccurrencesOfString:withString:options:range:

并且不要使用NSCaseInsensitiveSearch 选项。

【讨论】:

  • 他已经知道了,因为这显然是他正在使用的选项。
  • 应该使用什么选项而不是NSCaseInsensitiveSearch
  • @HarikrishnanT 输入0 无选择。
  • 对话流畅。 :-)
猜你喜欢
  • 2014-04-11
  • 1970-01-01
  • 1970-01-01
  • 2011-03-01
  • 1970-01-01
  • 2010-09-21
  • 1970-01-01
  • 1970-01-01
  • 2012-02-08
相关资源
最近更新 更多