@@ -79,19 +79,14 @@ extension String {
7979
8080 /// Replace _ - and + with a .
8181 ///
82- func replaceUnderscoreDashAndPlusWithDot( inString: String ) -> String {
83- var outString = inString
84- let replaceTargets = [ " _ " , " - " , " + " ]
85- for replaceTarget in replaceTargets {
86- outString = outString. replacingOccurrences ( of: replaceTarget, with: " . " )
87- }
88- return outString
82+ func replaceUnderscoreDashAndPlusWithDot( _ string: String ) -> String {
83+ string. replacingOccurrences ( of: " ([_ \\ -+]+) " , with: " . " , options: . regularExpression)
8984 }
9085
9186 /// Insert a . before and after any non number
9287 ///
93- func insertDotsBeforeAndAfterAnyNonNumber( inString : String ) -> String {
94- inString . replacingOccurrences ( of: " ([^0-9.]+) " , with: " .$1. " , options: . regularExpression)
88+ func insertDotsBeforeAndAfterAnyNonNumber( _ string : String ) -> String {
89+ string . replacingOccurrences ( of: " ([^0-9.]+) " , with: " .$1. " , options: . regularExpression)
9590 }
9691
9792 /// Score and compare two string components
@@ -125,8 +120,8 @@ extension String {
125120 /// Process the given string into version components
126121 ///
127122 func versionComponents( of string: String ) -> [ String ] {
128- var stringToComponentize = replaceUnderscoreDashAndPlusWithDot ( inString : string)
129- stringToComponentize = insertDotsBeforeAndAfterAnyNonNumber ( inString : stringToComponentize)
123+ var stringToComponentize = replaceUnderscoreDashAndPlusWithDot ( string)
124+ stringToComponentize = insertDotsBeforeAndAfterAnyNonNumber ( stringToComponentize)
130125 return stringToComponentize. components ( separatedBy: " . " )
131126 }
132127
0 commit comments