github.com/fufuok/utils@v1.0.10/xjson/match/DOC.md (about)

     1  <!-- Code generated by gomarkdoc. DO NOT EDIT -->
     2  
     3  # match
     4  
     5  ```go
     6  import "github.com/fufuok/utils/xjson/match"
     7  ```
     8  
     9  Package match provides a simple pattern matcher with unicode support.
    10  
    11  ## Index
    12  
    13  - [func Allowable(pattern string) (min, max string)](<#func-allowable>)
    14  - [func IsPattern(str string) bool](<#func-ispattern>)
    15  - [func Match(str, pattern string) bool](<#func-match>)
    16  - [func MatchLimit(str, pattern string, maxcomp int) (matched, stopped bool)](<#func-matchlimit>)
    17  
    18  
    19  ## func Allowable
    20  
    21  ```go
    22  func Allowable(pattern string) (min, max string)
    23  ```
    24  
    25  Allowable parses the pattern and determines the minimum and maximum allowable values that the pattern can represent. When the max cannot be determined, 'true' will be returned for infinite.
    26  
    27  ## func IsPattern
    28  
    29  ```go
    30  func IsPattern(str string) bool
    31  ```
    32  
    33  IsPattern returns true if the string is a pattern.
    34  
    35  ## func Match
    36  
    37  ```go
    38  func Match(str, pattern string) bool
    39  ```
    40  
    41  Match returns true if str matches pattern. This is a very simple wildcard match where '\*' matches on any number characters and '?' matches on any one character.
    42  
    43  pattern: \{ term \} term: '\*'         matches any sequence of non\-Separator characters '?'         matches any single non\-Separator character c           matches character c \(c \!= '\*', '?', '\\\\'\) '\\\\' c      matches character c
    44  
    45  ## func MatchLimit
    46  
    47  ```go
    48  func MatchLimit(str, pattern string, maxcomp int) (matched, stopped bool)
    49  ```
    50  
    51  MatchLimit is the same as Match but will limit the complexity of the match operation. This is to avoid long running matches, specifically to avoid ReDos attacks from arbritary inputs.
    52  
    53  How it works: The underlying match routine is recursive and may call itself when it encounters a sandwiched wildcard pattern, such as: \`user:\*:name\`. Everytime it calls itself a counter is incremented. The operation is stopped when counter \> maxcomp\*len\(str\).
    54  
    55  
    56  
    57  Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)