Skip to content

Commit

Permalink
add string remove prefix/suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
yume190 committed Aug 31, 2023
1 parent d536ecc commit f366974
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 17 deletions.
17 changes: 0 additions & 17 deletions Sources/LeakDetect/Command.swift
Original file line number Diff line number Diff line change
Expand Up @@ -123,20 +123,3 @@ struct Command: AsyncParsableCommand {
}
}

extension String {
func removeSuffix(_ text: String) -> String {
if self.hasSuffix(text) {
return String(self.dropLast(text.count))
} else {
return self
}
}

func removePrefix(_ text: String) -> String {
if self.hasPrefix(text) {
return String(self.dropFirst(text.count))
} else {
return self
}
}
}
26 changes: 26 additions & 0 deletions Sources/LeakDetectKit/String+Remove.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// String+Remove.swift
//
//
// Created by Yume on 2023/8/30.
//

import Foundation

public extension String {
func removeSuffix(_ text: String) -> String {
if self.hasSuffix(text) {
return String(self.dropLast(text.count))
} else {
return self
}
}

func removePrefix(_ text: String) -> String {
if self.hasPrefix(text) {
return String(self.dropFirst(text.count))
} else {
return self
}
}
}

0 comments on commit f366974

Please sign in to comment.