當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


GO Regexp.NumSubexp用法及代碼示例

GO語言"regexp"包中"Regexp.NumSubexp"類型的用法及代碼示例。

用法:

func(re *Regexp) NumSubexp() int

NumSubexp 返回此 Regexp 中帶括號的子表達式的數量。

例子:

package main

import (
	"fmt"
	"regexp"
)

func main() {
	re0 := regexp.MustCompile(`a.`)
	fmt.Printf("%d\n", re0.NumSubexp())

	re := regexp.MustCompile(`(.*)((a)b)(.*)a`)
	fmt.Println(re.NumSubexp())
}

輸出:

0
4

相關用法


注:本文由純淨天空篩選整理自golang.google.cn大神的英文原創作品 Regexp.NumSubexp。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。