UPE // Further optimization of regex processing.

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

View File

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