You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+43-1Lines changed: 43 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -5,14 +5,56 @@ Regular expression tools for Kotlin developers.
5
5
6
6
## RegexBuilder
7
7
8
-
`RegexBuilder` is a class for building regular expressions in a more human-readable way using a fluent API. It offers a number of benefits over using raw regex syntax in strings:
8
+
`RegexBuilder` is a class for building 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:
9
9
10
10
- No knowledge of regular expression syntax is required: just use simple, intuitively-named classes and methods.
11
11
- Code is easier to read, understand and maintain.
12
12
- Code is safer and far less prone to regular expression syntax errors and programmer errors.
13
13
14
14
It is fully documented in the [project wiki](https://github.com/markwhitaker/RegexToolbox.kt/wiki).
15
15
16
+
## New in version 2.0
17
+
18
+
### New builder syntax
19
+
20
+
Version 2.0 introduces a simplified [type-safe builder syntax](https://kotlinlang.org/docs/reference/type-safe-builders.html) for cleaner, less error-prone and more Kotliny code. Go from this:
21
+
22
+
```kotlin
23
+
val regex =RegexBuilder()
24
+
.startGroup()
25
+
.text()
26
+
.digit()
27
+
.buildRegex() // ERROR: forgot to call endGroup()
28
+
```
29
+
30
+
to this:
31
+
32
+
```kotlin
33
+
val regex = regex {
34
+
group {
35
+
text()
36
+
digit()
37
+
} // Yay! Can't forget to close the group
38
+
} // Yay! No need to call buildRegex()
39
+
```
40
+
41
+
The old syntax is still supported if that's your preference (and for consistency with the sibling projects listed at the bottom of the page).
42
+
43
+
### Quantifiers
44
+
45
+
`RegexQuantifier` is now a sealed class and its methods have become objects or classes. The old syntax is still supported but deprecated and will be removed in a future version.
0 commit comments