Regular expression tools for Kotlin developers.
RegexToolbox allows you to build regular expressions in a more human-readable way using a lightweight, powerful API. It offers a lot of benefits over using raw regex syntax in strings:
- No knowledge of regular expression syntax is required: just use simple, intuitively-named classes, methods and functions.
- Code is easier to read, understand and maintain.
- Code is safer and far less prone to regular expression syntax errors and programmer errors.
It is fully documented in the project wiki.
All RegexBuilder
features that were deprecated in version 2.4 have been removed in 3.0.
Removed | Replaced with |
---|---|
RegexBuilder() public constructor |
regex { ... } |
buildRegex() |
regex { ... } |
buildPattern() |
pattern { ... } |
startGroup() ... endGroup() |
group { ... } |
startNamedGroup() ... endGroup() |
namedGroup { ... } |
startNonCapturingGroup() ... endGroup() |
nonCapturingGroup { ... } |
addLogger() |
No replacement: logging has been removed. |
In a nutshell: the old Java-style syntax is completed removed in 3.0. RegexToolbox.kt now exclusively uses the new type-safe builder syntax introduced in 2.0, for example:
val regex = regex {
group {
letter()
digit()
} // Yay! Can't forget to close the group
} // Yay! No need to call buildRegex()
RegexToolbox.kt is hosted on JitPack.
Replace x.y.z
with the latest version (shown in the JitPack badge at the top of this page).
repositories {
...
maven { url 'https://jitpack.io' }
}
implementation 'com.github.markwhitaker:RegexToolbox.kt:x.y.z'
MimeTypes.kt: MIME type constants for your Kotlin projects