We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ad81078 commit 7fe920dCopy full SHA for 7fe920d
1 file changed
Sources/Task.swift
@@ -47,12 +47,14 @@ public struct Task {
47
}
48
49
private extension String {
50
+ static let whitespaceRegularExpression = try! NSRegularExpression(pattern: "\\s")
51
+
52
var escaped: String {
- if rangeOfCharacter(from: .whitespaces) != nil {
- return "\"\(self)\""
53
- } else {
54
- return self
55
- }
+ return String.whitespaceRegularExpression.stringByReplacingMatches(
+ in: self,
+ range: NSRange(location: 0, length: self.utf16.count),
56
+ withTemplate: "\\\\$0"
57
+ )
58
59
60
0 commit comments