package remap import ( "regexp" ) type ( // ReMap provides some map-related functions around a [regexp.Regexp]. ReMap struct { *regexp.Regexp } // TODO? /* ExplicitStringMatch is used with ReMap.MapStringExplicit to indicate if a capture group result is a hit (a group matched, but e.g. the match value is empty string) or not (a group did not match). */ /* ExplicitStringMatch struct { Group string IsMatch bool Value string } */ stringIndexer struct { // group is the capture group index for this match. group int // start is the string index (from the original string) where the matched group starts start int // end is the string index where the matched group ends end int /* matched indicates if explicitly no match was found. (This is normally indeterminate with string regex returns, as e.g. `(?P\s*)`, `(?P(?:somestring)?)`, etc. all can be a *matched* "".) If grpS == "" and matched == true, it DID match an empty string. If grpS == "" and matched == false, it DID NOT MATCH the pattern. If grpS != "", matched can be completely disregarded. */ matched bool // nm is the match group name. nm string /* grpS is the actual group-matched *substring*. It will ALWAYS be either: * the entirety of s * a substring of s * an empty string it will never, and cannot be, a SUPERset of s. it may not always be included/populated to save on memory. */ grpS string /* s is the *entire* MATCHED (sub)string. It may not always be populated if not needed to save memory. */ s *string // ptrn is the pattern applied to s. ptrn *regexp.Regexp } )