@import url/cutesoft_client/cuteeditor/load.ashx?type=style&file=syntaxhighlighter.css);
@import URL (/css/cuteeditor.css);
Give a call to an instance directly:
@import url/cutesoft_client/cuteeditor/load.ashx?type=style&file=syntaxhighlighter.css);
@import URL (/css/cuteeditor.css);
var str = "\ r \ n \ \ r \ n \ n \ n \ playground \ t \ \ \n\r \ n"
Let length = (str as nsstring). length
Let A = Str.escapeheadtailspace ()
Let B = str.stringescapeheadtail (strs:["\ r", "\ n", "T", "\ r \ n", ""])
corresponding Result:
A::\t Hello, \ Playground \ n
B::hello, \ Playground
The principle is: For a string, skip the given string one byte at a time, and return the newly obtained string, iterative until the given string is not found in the original string. In this way, the characters contained in the middle are not removed.
Reverses the resulting new string and processes it again. So the end of the tail of the set of excluded strings can be. The result is then reversed to get the original order of the string, which is the result we need.
Simply remove all of the character sets, there are native methods, do not reconsider
This is an extension for string:
Extension string{
Func escapespacetillcahractor ()->string{
Return Self.stringescapeheadtail (strs:["\ r", "", "\ n"])
}
Func escapeheadstr (str:string)-> (String, Bool) {
var result = self as NSString
var Findatleastone = False
while (true) {
var range = result.rangeofstring (str)
If range.location = = 0 && range.length = 1 {
result = Result.substringfromindex (range.length)
Findatleastone = True
}else{
Break
}
}
Return (result as String, Findatleastone)
}
Func escapespacetillcahractor (#strs: [String])->string{
var result = Self
while (true) {
var Findatleastone = False
For Str in STRs {
var Found:bool = False
(result, found) = Result.escapeheadstr (str)
If found {
Findatleastone = True
Break//for cycle
}
}
If Findatleastone = = False {
Break
}
}
return result as String
}
Func reverse ()->string{
var inreverse = ""
For letter in self {
println (letter)
Inreverse = "\ (letter)" + Inreverse
}
Return Inreverse
}
Func escapeheadtailspace ()->string{
Return Self.escapespacetillcahractor (). Reverse (). Escapespacetillcahractor (). Reverse ()
}
Func Stringescapeheadtail (#strs: [String])->string{
Return Self.escapespacetillcahractor (strs:strs). Reverse (). Escapespacetillcahractor (Strs:strs). Reverse ()
}
}