github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/regexp/syntax/simplify.go (about)

     1  // Copyright 2011 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package syntax
     6  
     7  // Simplify returns a regexp equivalent to re but without counted repetitions
     8  // and with various other simplifications, such as rewriting /(?:a+)+/ to /a+/.
     9  // The resulting regexp will execute correctly but its string representation
    10  // will not produce the same parse tree, because capturing parentheses
    11  // may have been duplicated or removed. For example, the simplified form
    12  // for /(x){1,2}/ is /(x)(x)?/ but both parentheses capture as $1.
    13  // The returned regexp may share structure with or be the original.
    14  func (re *Regexp) Simplify() *Regexp