ogenregex

package
v0.60.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2023 License: Apache-2.0 Imports: 9 Imported by: 118 modules, 103 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ogenregex provides an interface to the regex engine.

JSON Schema specification prefers to use ECMA 262 regular expressions. However, Go's regex engine is based on RE2, which is a different engine. Also, Go's regex engine does not support lookbehind assertions, to ensure linear time matching.

This package provides unified interface to both engines. Go's regex engine is used by default, but if the regex is not supported, the dlclark/regexp2 would be used.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Convert

func Convert(pattern string) (string, bool)

Convert converts a ECMA-262 regular expression to Go's regular expression.

If the conversion is not possible, ("", false) is returned.

Types

type Regexp

type Regexp interface {
	Match(s []byte) (bool, error)
	MatchString(s string) (bool, error)
	String() string
}

Regexp is a regular expression interface.

func Compile

func Compile(exp string) (Regexp, error)

Compile compiles a regular expression.

NOTE: this function may compile the same expression multiple times and can be slow. Compile the expression once and reuse it.

func MustCompile

func MustCompile(exp string) Regexp

MustCompile compiles a regular expression and panics on error.

NOTE: this function may compile the same expression multiple times and can be slow. Compile the expression once and reuse it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL