Golang regexp.NumSubexp() function example
package regexp
Golang regexp.NumSubexp() function usage example
package main
import (
"fmt"
"regexp"
)
func main() {
// regular expression pattern
regE := regexp.MustCompile("/oid/([\\d]+)/")
i := regE.NumSubexp()
fmt.Println("Number of parenthesized subexpressions : ", i)
// regular expression pattern
regE = regexp.MustCompile("/oid/([\\d]+)/([\\d]+)")
r := regE.NumSubexp()
fmt.Println("Number of parenthesized subexpressions : ", r)
}
Output :
Number of parenthesized subexpressions : 1
Number of parenthesized subexpressions : 2
Reference :
Advertisement
Something interesting
Tutorials
+16.3k Golang : Find out mime type from bytes in buffer
+17k Golang : How to save log messages to file?
+10.3k Golang : How to check if a website is served via HTTPS
+20.8k Golang : Underscore or snake_case to camel case example
+9.6k Golang : How to extract video or image files from html source code
+6.2k PHP : How to handle URI or URL with non-ASCII characters such as Chinese/Japanese/Korean(CJK) ?
+5.8k Unix/Linux : How to test user agents blocked successfully ?
+7.1k Golang : Get Alexa ranking data example
+13.9k Golang : Human readable time elapsed format such as 5 days ago
+6.9k Mac/Linux/Windows : Get CPU information from command line
+25.9k Golang : How to read integer value from standard input ?
+21.1k Golang : Convert(cast) string to rune and back to string example