From 8e658dfab85ad198d4003c7d58c840ba6029e031 Mon Sep 17 00:00:00 2001 From: Svjatoslav Agejenko Date: Sun, 30 Aug 2020 23:34:57 +0300 Subject: [PATCH] show regexp groups, handy for debugging --- .../string/tokenizer/TokenizerMatch.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/eu/svjatoslav/commons/string/tokenizer/TokenizerMatch.java b/src/main/java/eu/svjatoslav/commons/string/tokenizer/TokenizerMatch.java index ebe5175..cd07ec9 100755 --- a/src/main/java/eu/svjatoslav/commons/string/tokenizer/TokenizerMatch.java +++ b/src/main/java/eu/svjatoslav/commons/string/tokenizer/TokenizerMatch.java @@ -50,10 +50,19 @@ public class TokenizerMatch { @Override public String toString() { - return "TokenizerMatch{" + - "token='" + token + '\'' + - ", terminator=" + terminator + - '}'; + StringBuilder result = new StringBuilder(); + result.append("TokenizerMatch\n" + + " token='" + token + "'\n" + + " terminator=" + terminator + "\n" + + " groups:\n"); + + int i = 0; + for (String s : getRegExpGroups()) { + result.append(" " + i + ": " + s + "\n"); + i++; + } + + return result.toString(); } public Tokenizer getTokenizer() { -- 2.20.1