regex icon indicating copy to clipboard operation
regex copied to clipboard

Match: show (only?) matched text in Debug output

Open masklinn opened this issue 7 years ago • 1 comments

The current output when debug-printing a Match (especially from a large haystack) is pretty terrifying as it shows the entire source string, and unless one's taken a gander at the underlying implementation it looks like way more stuff has been matched than expected and the pattern is completely wrong. I've done exactly that several time, and every time I forget about this thing and wonder why my patterns are broken

Alternatively, maybe implement Display or Deref to an str so one can just println!-it and see the result?

masklinn avatar Sep 14 '18 12:09 masklinn

A match includes the match offsets, so it should be possible to improve the Debug such that it only shows just the matched portion of the string. I definitely agree with doing that.

I think I'd be firmly opposed to implementing Display or Deref though.

BurntSushi avatar Sep 14 '18 13:09 BurntSushi

Nice, thanks!

masklinn avatar Apr 18 '23 17:04 masklinn