UPE // Further optimization of regex processing.

This commit is contained in:
ShikiSuen 2022-03-10 12:11:08 +08:00
parent da925e58c6
commit a8caee8e8d
1 changed files with 2 additions and 2 deletions

View File

@ -37,8 +37,8 @@ extension String {
// Tab to ASCII Space // Tab to ASCII Space
// ASCII // ASCII
strProcessed.regReplace(pattern: #"( +| +| +|\t+)+"#, replaceWith: " ") strProcessed.regReplace(pattern: #"( +| +| +|\t+)+"#, replaceWith: " ")
strProcessed.regReplace(pattern: #"(\f+|\r+)+"#, replaceWith: "\n") // CR & Form Feed to LF strProcessed.regReplace(pattern: #"(^ | $)"#, replaceWith: "") //
strProcessed.regReplace(pattern: #"(\n+| \n+|\n+ )"#, replaceWith: "\n") // strProcessed.regReplace(pattern: #"(\f+|\r+|\n+)+"#, replaceWith: "\n") // CR & Form Feed to LF,
if strProcessed.prefix(1) == " " { // if strProcessed.prefix(1) == " " { //
strProcessed.removeFirst() strProcessed.removeFirst()
} }