Socket
Socket
Sign inDemoInstall

rsc.io/binaryregexp

Package Overview
Dependencies
0
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    rsc.io/binaryregexp

Package regexp implements regular expression search. The syntax of the regular expressions accepted is the same general syntax used by Perl, Python, and other languages. More precisely, it is the syntax accepted by RE2 and described at https://golang.org/s/re2syntax, except for \C. For an overview of the syntax, run The regexp implementation provided by this package is guaranteed to run in time linear in the size of the input. (This is a property not guaranteed by most open source implementations of regular expressions.) For more information about this property, see or any book about automata theory. All characters are UTF-8-encoded code points. There are 16 methods of Regexp that match a regular expression and identify the matched text. Their names are matched by this regular expression: If 'All' is present, the routine matches successive non-overlapping matches of the entire expression. Empty matches abutting a preceding match are ignored. The return value is a slice containing the successive return values of the corresponding non-'All' routine. These routines take an extra integer argument, n. If n >= 0, the function returns at most n matches/submatches; otherwise, it returns all of them. If 'String' is present, the argument is a string; otherwise it is a slice of bytes; return values are adjusted as appropriate. If 'Submatch' is present, the return value is a slice identifying the successive submatches of the expression. Submatches are matches of parenthesized subexpressions (also known as capturing groups) within the regular expression, numbered from left to right in order of opening parenthesis. Submatch 0 is the match of the entire expression, submatch 1 the match of the first parenthesized subexpression, and so on. If 'Index' is present, matches and submatches are identified by byte index pairs within the input string: result[2*n:2*n+1] identifies the indexes of the nth submatch. The pair for n==0 identifies the match of the entire expression. If 'Index' is not present, the match is identified by the text of the match/submatch. If an index is negative or text is nil, it means that subexpression did not match any string in the input. For 'String' versions an empty string means either no match or an empty match. There is also a subset of the methods that can be applied to text read from a ByteReader: This set may grow. Note that regular expression matches may need to examine text beyond the text returned by a match, so the methods that match text from a ByteReader may read arbitrarily far into the input before returning. (There are a few other methods that do not match this pattern.)


Version published

Readme

Source

AT&T POSIX Test Files See textregex.c for copyright + license.

testregex.c http://www2.research.att.com/~gsf/testregex/testregex.c basic.dat http://www2.research.att.com/~gsf/testregex/basic.dat nullsubexpr.dat http://www2.research.att.com/~gsf/testregex/nullsubexpr.dat repetition.dat http://www2.research.att.com/~gsf/testregex/repetition.dat

The test data has been edited to reflect RE2/Go differences:

  • In a star of a possibly empty match like (a*)* matching x, the no match case runs the starred subexpression zero times, not once. This is consistent with (a*)* matching a, which runs the starred subexpression one time, not twice.
  • The submatch choice is first match, not the POSIX rule.

Such changes are marked with 'RE2/Go'.

RE2 Test Files

re2-exhaustive.txt.bz2 and re2-search.txt are built by running 'make log' in the RE2 distribution https://github.com/google/re2/

The exhaustive file is compressed because it is huge.

FAQs

Last updated on 24 May 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc