Skip to content

Commit 8a40e1c

Browse files
author
Mark Whitaker
authored
Added logging
1 parent 37c2498 commit 8a40e1c

6 files changed

Lines changed: 768 additions & 140 deletions

File tree

README.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,41 @@ Regular expression tools for Java developers.
1313
- Code is easier to read, understand and maintain.
1414
- Code is safer and far less prone to regular expression syntax errors and programmer errors.
1515

16-
It is fully documented in the [project wiki](https://github.com/markwhitaker/RegexToolbox.Java/wiki).
16+
Here's an example:
17+
18+
```java
19+
Pattern regex = new RegexBuilder()
20+
.text("Hello")
21+
.whitespace(RegexQuantifier.oneOrMore())
22+
.text("world!")
23+
.buildRegex();
24+
```
25+
26+
But that's just a taste of what `RegexBuilder` does: for full API documentation, head over to the [project wiki](https://github.com/markwhitaker/RegexToolbox.Java/wiki).
27+
28+
## New in 1.3: Logging
29+
30+
Use the new `addLogger()` method to connect a logger of your choice and see how your regex is built, step by step. For example:
31+
32+
```java
33+
Pattern regex = new RegexBuilder()
34+
.addLogger(s -> System.out.println(s))
35+
.wordBoundary()
36+
.text("Regex")
37+
.anyOf("Builder", "Toolbox")
38+
.wordBoundary()
39+
.buildRegex();
40+
```
41+
42+
will output this to your console:
43+
44+
```text
45+
RegexBuilder: wordBoundary(): \b
46+
RegexBuilder: text("Regex"): Regex
47+
RegexBuilder: anyOf("Builder", "Toolbox"): (?:Builder|Toolbox)
48+
RegexBuilder: wordBoundary(): \b
49+
RegexBuilder: buildRegex(): \bRegex(?:Builder|Toolbox)\b
50+
```
1751

1852
## Usage (Gradle)
1953

build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
buildscript {
22
ext.junit_version = '4.12'
3+
ext.mockito_version = '3.1.0'
34
}
45

56
plugins {
@@ -22,6 +23,8 @@ sourceCompatibility = 1.8
2223

2324
dependencies {
2425
testImplementation "junit:junit:$junit_version"
26+
testImplementation "org.mockito:mockito-core:$mockito_version"
27+
testImplementation "org.mockito:mockito-inline:$mockito_version"
2528
}
2629

2730
bintray {

0 commit comments

Comments
 (0)