Home | History | Annotate | Download | only in regexp

Lines Matching refs:regexp

5 // Package regexp implements regular expression search.
12 // go doc regexp/syntax
14 // The regexp implementation provided by this package is
19 // http://swtch.com/~rsc/regexp/regexp1.html
24 // There are 16 methods of Regexp that match a regular expression and identify
65 package regexp
70 "regexp/syntax"
78 // Regexp is the representation of a compiled regular expression.
79 // A Regexp is safe for concurrent use by multiple goroutines.
80 type Regexp struct {
84 // cache of machines for running regexp
95 prefixComplete bool // prefix is the entire regexp
105 func (re *Regexp) String() string {
109 // Copy returns a new Regexp object copied from re.
111 // When using a Regexp in multiple goroutines, giving each goroutine
113 func (re *Regexp) Copy() *Regexp {
114 // It is not safe to copy Regexp by value
116 return &Regexp{
122 // a Regexp object that can be used to match against text.
124 // When matching against text, the regexp returns a match that
131 func Compile(expr string) (*Regexp, error) {
139 // That is, when matching against text, the regexp returns a match that
153 // See http://swtch.com/~rsc/regexp/regexp2.html#posix for details.
154 func CompilePOSIX(expr string) (*Regexp, error) {
159 // That is, when matching against text, the regexp returns a match that
162 func (re *Regexp) Longest() {
166 func compile(expr string, mode syntax.Flags, longest bool) (*Regexp, error) {
179 regexp := &Regexp{
190 if regexp.onepass == notOnePass {
191 regexp.prefix, regexp.prefixComplete = prog.Prefix()
193 regexp.prefix, regexp.prefixComplete, regexp.prefixEnd = onePassPrefix(prog)
195 if regexp.prefix != "" {
198 regexp.prefixBytes = []byte(regexp.prefix)
199 regexp.prefixRune, _ = utf8.DecodeRuneInString(regexp.prefix)
201 return regexp, nil
207 func (re *Regexp) get() *machine {
225 func (re *Regexp) put(z *machine) {
234 func MustCompile(str string) *Regexp {
235 regexp, error := Compile(str)
237 panic(`regexp: Compile(` + quote(str) + `): ` + error.Error())
239 return regexp
245 func MustCompilePOSIX(str string) *Regexp {
246 regexp, error := CompilePOSIX(str)
248 panic(`regexp: CompilePOSIX(` + quote(str) + `): ` + error.Error())
250 return regexp
260 // NumSubexp returns the number of parenthesized subexpressions in this Regexp.
261 func (re *Regexp) NumSubexp() int {
266 // in this Regexp. The name for the first sub-expression is names[1],
268 // Since the Regexp as a whole cannot be named, names[0] is always
270 func (re *Regexp) SubexpNames() []string {
281 hasPrefix(re *Regexp) bool
282 index(re *Regexp, pos int) int
306 func (i *inputString) hasPrefix(re *Regexp) bool {
310 func (i *inputString) index(re *Regexp, pos int) int {
345 func (i *inputBytes) hasPrefix(re *Regexp) bool {
349 func (i *inputBytes) index(re *Regexp, pos int) int {
389 func (i *inputReader) hasPrefix(re *Regexp) bool {
393 func (i *inputReader) index(re *Regexp, pos int) int {
404 func (re *Regexp) LiteralPrefix() (prefix string, complete bool) {
408 // MatchReader reports whether the Regexp matches the text read by the
410 func (re *Regexp) MatchReader(r io.RuneReader) bool {
414 // MatchString reports whether the Regexp matches the string s.
415 func (re *Regexp) MatchString(s string) bool {
419 // Match reports whether the Regexp matches the byte slice b.
420 func (re *Regexp) Match(b []byte) bool {
426 // the full Regexp interface.
437 // to use Compile and the full Regexp interface.
448 // to use Compile and the full Regexp interface.
457 // ReplaceAllString returns a copy of src, replacing matches of the Regexp
460 func (re *Regexp) ReplaceAllString(src, repl string) string {
471 // ReplaceAllLiteralString returns a copy of src, replacing matches of the Regexp
474 func (re *Regexp) ReplaceAllLiteralString(src, repl string) string {
481 // Regexp have been replaced by the return value of function repl applied
484 func (re *Regexp) ReplaceAllStringFunc(src string, repl func(string) string) string {
491 func (re *Regexp) replaceAll(bsrc []byte, src string, nmatch int, repl func(dst []byte, m []int) []byte) []byte {
556 // ReplaceAll returns a copy of src, replacing matches of the Regexp
559 func (re *Regexp) ReplaceAll(src, repl []byte) []byte {
574 // ReplaceAllLiteral returns a copy of src, replacing matches of the Regexp
577 func (re *Regexp) ReplaceAllLiteral(src, repl []byte) []byte {
584 // Regexp have been replaced by the return value of function repl applied
587 func (re *Regexp) ReplaceAllFunc(src []byte, repl func([]byte) []byte) []byte {
630 // to fewer capturing expressions than are in the regexp.
634 func (re *Regexp) pad(a []int) []int {
647 func (re *Regexp) allMatches(s string, b []byte, n int, deliver func([]int)) {
695 func (re *Regexp) Find(b []byte) []byte {
708 func (re *Regexp) FindIndex(b []byte) (loc []int) {
721 func (re *Regexp) FindString(s string) string {
734 func (re *Regexp) FindStringIndex(s string) (loc []int) {
747 func (re *Regexp) FindReaderIndex(r io.RuneReader) (loc []int) {
760 func (re *Regexp) FindSubmatch(b []byte) [][]byte {
792 func (re *Regexp) Expand(dst []byte, template []byte, src []byte, match []int) []byte {
799 func (re *Regexp) ExpandString(dst []byte, template string, src string, match []int) []byte {
803 func (re *Regexp) expand(dst []byte, template string, bsrc []byte, src string, match []int) []byte {
908 func (re *Regexp) FindSubmatchIndex(b []byte) []int {
917 func (re *Regexp) FindStringSubmatch(s string) []string {
937 func (re *Regexp) FindStringSubmatchIndex(s string) []int {
946 func (re *Regexp) FindReaderSubmatchIndex(r io.RuneReader) []int {
956 func (re *Regexp) FindAll(b []byte, n int) [][]byte {
974 func (re *Regexp) FindAllIndex(b []byte, n int) [][]int {
992 func (re *Regexp) FindAllString(s string, n int) []string {
1010 func (re *Regexp) FindAllStringIndex(s string, n int) [][]int {
1028 func (re *Regexp) FindAllSubmatch(b []byte, n int) [][][]byte {
1052 func (re *Regexp) FindAllSubmatchIndex(b []byte, n int) [][]int {
1070 func (re *Regexp) FindAllStringSubmatch(s string, n int) [][]string {
1095 func (re *Regexp) FindAllStringSubmatchIndex(s string, n int) [][]int {
1117 // s := regexp.MustCompile("a*").Split("abaabaccadaaae", 5)
1124 func (re *Regexp) Split(s string, n int) []string {