0

For example, I have a bunch of HTML entries ending in /"> and I want everything BEFORE this chunk. Is there a built-in method to get this done?

Maybe there is something like replaceOcurrencesOfString() that looks something like removeRangeAfterOcurrenceOfString() ?

Example:

I need this:

some-html-link-ending/">

To look like this:

some-html-link-ending
swiftyboi
  • 2,675
  • 3
  • 23
  • 50

1 Answers1

1

You can use this

mutating func replace(originalString:String, withString newString:String)
{
    let replacedString = self.stringByReplacingOccurrencesOfString(originalString, withString: newString, options: nil, range: nil)
    self = replacedString
} 

Use:

name.replace("/">", withString: " ")
Moin Shirazi
  • 4,276
  • 2
  • 25
  • 37