ios - Search, replace and highlighting String in Swift 2.0 -


i want search specific string , replace same string without changing case.

lets have following string - 'good morning. good.', want search 'good' , highlight different color, have maintain same case.

i tried 'stringbyreplacingoccurrencesofstring()', problem here replaces 'good' 'good', need maintain case of string.

how can achieved?

  1. lowercase copy of string ie 'good morning...'
  2. iterate through string looking key words ie 'good'
  3. when found, record index , length in separate array.
  4. go original string , update colour.

Comments