mirror of
https://github.com/whoeevee/EeveeSpotifyReborn.git
synced 2026-01-09 00:23:20 +01:00
Genius Lyrics (I so like it)
This commit is contained in:
1 parent
aca33323f5
commit
04bad04ac9
24 files changed
+765
-2
No files matched your search
@@ -1,10 +1,32 @@
|
||||
import Foundation
|
||||
|
||||
extension String {
|
||||
|
||||
|
||||
static func ~= (lhs: String, rhs: String) -> Bool {
|
||||
guard let regex = try? NSRegularExpression(pattern: rhs) else { return false }
|
||||
let range = NSRange(location: 0, length: lhs.utf16.count)
|
||||
return regex.firstMatch(in: lhs, options: [], range: range) != nil
|
||||
}
|
||||
|
||||
var range: NSRange {
|
||||
NSRange(self.startIndex..., in: self)
|
||||
}
|
||||
|
||||
func containsInsensitive<S: StringProtocol>(_ s: S) -> Bool {
|
||||
self.range(of: s, options: .caseInsensitive) != nil
|
||||
}
|
||||
|
||||
func matches(_ pattern: String) -> Bool {
|
||||
try! NSRegularExpression(pattern: pattern)
|
||||
.firstMatch(in: self, range: self.range) != nil
|
||||
}
|
||||
|
||||
func removeMatches(_ pattern: String) -> String {
|
||||
try! NSRegularExpression(pattern: pattern)
|
||||
.stringByReplacingMatches(
|
||||
in: self,
|
||||
range: self.range,
|
||||
withTemplate: ""
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user