package main

import (
	"fmt"
	"regexp"
)

func main() {
	str := "/gocloud.api.wms.v1.hello.HelloService/Read"
	regExp := regexp.MustCompile("/gocloud.api.wms.v1.([a-zA-Z.]+)/([a-zA-Z]+)")
	match := regExp.FindStringSubmatch(str)
	if len(match) == 0 {
		fmt.Println("No match found!")
		return
	}
	fmt.Println('HelloService: ', match[1])
	fmt.Println('Read: ', match[2])
}
Golang 正则表达式解析 API 路径

原文地址: https://www.cveoy.top/t/topic/lh2A 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录