]> Cypherpunks repositories - gostls13.git/commit
regexp/syntax: use more compact Regexp.String output
authorRuss Cox <rsc@golang.org>
Wed, 28 Jun 2023 21:45:26 +0000 (17:45 -0400)
committerGopher Robot <gobot@golang.org>
Wed, 16 Aug 2023 16:02:30 +0000 (16:02 +0000)
commit98c9f271d67b501ecf2ce995539abd2cdc81d505
tree41509327c105a85923bcdd368146570b87d531da
parent5a3048bf0eefd2f99382a980f975d6a1fb6b921a
regexp/syntax: use more compact Regexp.String output

Compact the Regexp.String output. It was only ever intended for debugging,
but there are at least some uses in the wild where regexps are built up
using regexp/syntax and then formatted using the String method.
Compact the output to help that use case. Specifically:

 - Compact 2-element character class ranges: [a-b] -> [ab].
 - Aggregate flags: (?i:A)(?i:B)*(?i:C)|(?i:D)?(?i:E) -> (?i:AB*C|D?E).

Fixes #57950.

Change-Id: I1161d0e3aa6c3ae5a302677032bb7cd55caae5fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/507015
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
src/regexp/syntax/parse.go
src/regexp/syntax/parse_test.go
src/regexp/syntax/regexp.go
src/regexp/syntax/simplify_test.go