We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2c3c58f commit 67a83ceCopy full SHA for 67a83ce
1 file changed
Tool/Sources/SuggestionProvider/String+Extension.swift
@@ -8,4 +8,26 @@ public extension String {
8
}
9
return String(text)
10
11
+
12
+ func removedTrailingCharacters(in set: CharacterSet) -> String {
13
+ var text = self[...]
14
+ while let last = text.last, set.containsUnicodeScalars(of: last) {
15
+ text = text.dropLast(1)
16
+ }
17
+ return String(text)
18
19
20
+ func removeLeadingCharacters(in set: CharacterSet) -> String {
21
22
+ while let first = text.first, set.containsUnicodeScalars(of: first) {
23
+ text = text.dropFirst()
24
25
26
27
+}
28
29
+extension CharacterSet {
30
+ func containsUnicodeScalars(of character: Character) -> Bool {
31
+ return character.unicodeScalars.allSatisfy(contains(_:))
32
33
0 commit comments