Skip to content

This packages makes it possible to efficiently replace regular expression with template containing `$1`, `S2`, etc.

License

Notifications You must be signed in to change notification settings

stefanspringer1/RegexTemplates

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RegexTemplates

This package makes it possible to efficiently replace a regular expression with a template containing $1, S2, etc.

Example:

print(#replaceWithTemplate(in: "123 hello!", replace: /([a-z]+)/, withTemplate: "$1 $1"))
// prints "123 hello hello!"

Example with matching semantics .unicodeScalar:

print(#replaceWithTemplate(in: "a\u{0307}", replace: /([a-z])\x{0307}/.matchingSemantics(.unicodeScalar), withTemplate: "$1\u{0300}"))
// prints "à"

About

This packages makes it possible to efficiently replace regular expression with template containing `$1`, `S2`, etc.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages