```
str := "abc a7c mfc cat aMc azc cba"
// 解析、編譯正則表達式
//ret := regexp.MustCompile(`a.c`) // `` : 表示使用原生字符串
ret := regexp.MustCompile(`a[^0-9a-z]c`) // `` : 表示使用原生字符串
// 提取需要信息
alls := ret.FindAllStringSubmatch(str, -1)
fmt.Println("alls:", alls)
```
```
str := "3.14 123.123 .68 haha 1.0 abc 7. ab.3 66.6 123."
// 解析、編譯正則表達式
//ret := regexp.MustCompile(`[0-9]+\.[0-9]+`)
//ret := regexp.MustCompile(`\d+\.\d+`)
ret := regexp.MustCompile(`\d\.\d`)
// 提取需要的信息
alls := ret.FindAllStringSubmatch(str, -1)
fmt.Println("alls:", alls)
```
```
func main() {
str := `<html lang="zh-CN">
<head>
<title>Go語言標準庫文檔中文版 | Go語言中文網 | Golang中文社區 | Golang中國</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
<meta charset="utf-8">
<link rel="shortcut icon" href="/static/img/go.ico">
<link rel="apple-touch-icon" type="image/png" href="/static/img/logo2.png">
<meta name="author" content="polaris <polaris@studygolang.com>">
<meta name="keywords" content="中文, 文檔, 標準庫, Go語言,Golang,Go社區,Go中文社區,Golang中文社區,Go語言社區,Go語言學習,學習Go語言,Go語言學習園地,Golang 中國,Golang中國,Golang China, Go語言論壇, Go語言中文網">
<meta name="description" content="Go語言文檔中文版,Go語言中文網,中國 Golang 社區,Go語言學習園地,致力于構建完善的 Golang 中文社區,Go語言愛好者的學習家園。分享 Go 語言知識,交流使用經驗">
</head>
<title></title>
<div>hello regexp</div>
<div>hello 2</div>
<div>hello 890</div>
<div>hello 664</div>
<div>
2塊錢啥時候還?
過了年再說吧!
剛買了車,沒錢。。。
</div>
<body>身體</body>
<frameset cols="15,85">
<frame src="/static/pkgdoc/i.html">
<frame name="main" src="/static/pkgdoc/main.html" tppabs="main.html" >
<noframes>
</noframes>
</frameset>
</html>`
// 解析、編譯正則表達式
//ret := regexp.MustCompile(`<div>(.*)</div>`)
ret := regexp.MustCompile(`<div>(?s:(.*?))</div>`)
// 提取需要的信息
alls := ret.FindAllStringSubmatch(str, -1)
fmt.Println("alls:", alls)
for _, one := range alls {
fmt.Println("one[0]=", one[0])
fmt.Println("one[1]=", one[1])
}
}
```
- 認識Golang
- 環境配置
- 找不到包
- civil
- 語言基礎
- 執行流程
- 標準命令
- 輸入輸出
- 常量與變量
- 常量的定義和使用
- 變量
- 枚舉
- 數據類型
- 結構體
- 定義和使用
- 函數參數
- 普通數據類型
- 數值型
- 整型
- 浮點類型
- 布爾
- 字符
- 字符串
- 類型轉換
- 復雜數據類型
- 指針
- 定義和使用
- 空指針
- 野指針
- new
- 函數參數
- 數組
- 定義
- 切片
- 切片
- Map
- 定義和使用
- 流程控制
- if
- switch
- for
- break
- continue
- goto
- 函數
- 函數的定義與使用
- 不定參函數
- 函數返回值
- 作用域
- 匿名函數
- 閉包
- 傳值方式
- 常用函數
- 日期
- 包
- 面向對象
- 異常處理
- 文件讀寫
- 正則
- io
- Reader
- Writer
- 接口
- 測試
- os
- json
- Marshal
- Unmarshal
- 網絡編程
- go程
- runtime
- channel
- 無緩沖channel
- 關閉channel
- 單向channel
- 生產者消費者模型
- 定時器
- tcp
- tcp_server
- tcp_client
- tcp_server_并發
- tcp_client_并發
- 常用框架
- http
- server
- get
- head
- 爬蟲
- 百度貼吧
- 百度貼吧( 并發)
- GTK
- beego
- 環境搭建
- model
- 增
- 刪
- 改
- 查
- 模塊
- context
- httplib
- etcd
- 簡介
- 安裝
- 使用
- net/html
- goquery
- redis
- redigo
- 爬蟲
- gocolly/colly
- 區塊鏈
- 微服務
- 服務發現
- consul
- 簡介