首次提交:初始化项目代码
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
var userRegex = regexp.MustCompile(`姓名:([\p{Han}a-zA-Z0-9]+),年龄:(\d+),电话:(\d{11})`)
|
||||
|
||||
func main() {
|
||||
text := "用户信息:姓名:孙三苗,年龄:20,电话:11112345678" // 号码不存在仅供测试
|
||||
match := userRegex.FindStringSubmatch(text)
|
||||
if len(match) > 0 {
|
||||
fmt.Println("完整匹配:", match[0])
|
||||
fmt.Println("姓名:", match[1])
|
||||
fmt.Println("年龄:", match[2])
|
||||
fmt.Println("电话:", match[3])
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user