go 正则贪婪匹配

180it 2020-10-26 PM 58℃ 0条
package main

import (
    "fmt"
    "regexp"

)
func main(){

    r,_:=regexp.Compile("aaa(.*?)bbb")

    matches:=r.FindAllString("42342342aaa111111111111bbbasdfafasdfas",-1)
    // %q quote element to see... instead of %s
    fmt.Printf("%q \n",matches)

    for _,m:=range matches {
        fmt.Println(m)
    }

}
支付宝打赏支付宝打赏 微信打赏微信打赏

如果文章或资源对您有帮助,欢迎打赏作者。一路走来,感谢有您!

标签: none

go 正则贪婪匹配