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,965
  • 4
  • 25
  • 52

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,372
  • 2
  • 26
  • 38