Releases: markwhitaker/RegexToolbox.kt
Breaking changes: deprecated features have been removed
Summary
Version 3.0 marks a switchover to the new type-safe builder syntax introduced in 2.0: the old Java-style syntax that was deprecated in 2.4.0 has now been removed.
In addition, the logging API is removed in this release.
Changes in detail:
RegexBuilder()
public constructor removed: replace withregex { ... }
buildRegex()
removed: replace withregex { ... }
buildPattern()
removed: replace withpattern { ... }
startGroup() ... endGroup()
removed: replace withgroup { ... }
startNamedGroup() ... endGroup()
removed: replace withnamedGroup { ... }
startNonCapturingGroup() ... endGroup()
removed: replace withnonCapturingGroup { ... }
addLogger()
removed: no replacement
Deprecated outgoing features ready for 3.0
The following features are deprecated in this release and will be removed in 3.0:
- The old Java-style syntax (
RegexBuilder()...buildRegex()
) is deprecated. You should replace this with the new type-safe builder syntax (regex { ... }
). - Likewise the old grouping syntax (
startGroup()...endGroup()
) is deprecated. You should replace this with the new type-safe builder syntax (group { ... }
). - Logging is deprecated as it didn't add as much value as intended and causes an additional maintenance overhead.
Deprecated outgoing features ready for 3.0
The following features are deprecated in this release and will be removed in 3.0:
- The old Java-style syntax (
RegexBuilder()...buildRegex()
) is deprecated. You should replace this with the new type-safe builder syntax (regex { ... }
). - Likewise the old grouping syntax (
startGroup()...endGroup()
) is deprecated. You should replace this with the new type-safe builder syntax (group { ... }
). - Logging is deprecated as it didn't add as much value as intended and causes an additional maintenance overhead.
New extension methods
Added the following extension methods:
Regex.remove(input: CharSequence)
Regex.removeFirst(input: CharSequence)
Regex.removeLast(input: CharSequence)
CharSequence.remove(regex: Regex)
CharSequence.removeFirst(regex: Regex)
CharSequence.removeLast(regex: Regex)
Also removed deprecated properties from RegexQuantifier
.
New extension methods
Added the following extension methods:
Regex.remove(input: CharSequence)
Regex.removeFirst(input: CharSequence)
Regex.removeLast(input: CharSequence)
CharSequence.remove(regex: Regex)
CharSequence.removeFirst(regex: Regex)
CharSequence.removeLast(regex: Regex)
Also removed deprecated properties from RegexQuantifier
.
Added logging support
Attach a logger using the new RegexBuilder.addLogger()
API to peep under the hood and see how your regex is being built, step by step.
Fix for anyCharacterFrom() and anyCharacterExcept()
Fixed bug in anyCharacterFrom() and anyCharacterExcept() so they work as documented
Support for Unicode letters
The following RegexBuilder
methods now support Unicode letters:
letter()
nonLetter()
uppercaseLetter()
lowercaseLetter()
letterOrDigit()
nonLetterOrDigit()
wordCharacter()
nonWordCharacter()
New Kotlin DSL-style syntax and improved quantifiers
This release adds a type-safe builder DSL-style syntax so you can now replace this:
val regex = RegexBuilder()
.startGroup()
.letter()
.digit()
.buildRegex() // ERROR! forgot to close group
with this:
val regex = regex {
group {
letter()
digit()
} // Yay! Can't forget to close a group
} // Yay! No need to call buildRegex()
It also makes Quantifiers a bit cleaner. Instead of this:
text(zeroOrMore())
You now do this:
text(ZeroOrMore) // Initial capital (bacause it's now a class), no brackets
Restored deprecated members of RegexQuantifier (with @Deprecated annotations)
2.0.0-alpha-2 Updated README.md