String
extension String
-
Returns a new string where the first match is replaced with the template.
You can use template variables like
$and$0in the template. More info.import Regex "123🦄456".replacingFirstMatch(of: Regex(#"\d+"#), with: "") //=> "🦄456"Declaration
Swift
public func replacingFirstMatch( of regex: Regex, with template: String ) -> Self -
Returns a new string where the first match is replaced with the template.
You can use template variables like
$and$0in the template. More info.import Regex "123🦄456".replacingFirstMatch(of: #"\d+"#, with: "") //=> "🦄456"Declaration
Swift
public func replacingFirstMatch( of regexPattern: StaticString, with template: String ) -> Self -
Returns a new string where all matches are replaced with the template.
You can use template variables like
$and$0in the template. More info.import Regex "123🦄456".replacingAllMatches(of: Regex(#"\d+"#), with: "") //=> "🦄" -
Returns a new string where all matches are replaced with the template.
You can use template variables like
$and$0in the template. More info.import Regex "123🦄456".replacingAllMatches(of: #"\d+"#, with: "") //=> "🦄"Declaration
Swift
public func replacingAllMatches( of regexPattern: StaticString, with template: String, options: Regex.MatchingOptions = [] ) -> Self
View on GitHub
Install in Dash
String Extension Reference