-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpatterns.go
More file actions
27 lines (24 loc) · 1002 Bytes
/
patterns.go
File metadata and controls
27 lines (24 loc) · 1002 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package goini
import (
"regexp"
)
const (
FirstSection string = `^(?U)(\[.*\])` // 节匹配 只解析第一个符合规范的节名
Section string = `\s+|\[|\]|\*+` // 节匹配
Node string = `.*=.*` // 节点匹配
Separator string = `(\.\.+)` // key中是否含有连续的分隔符
QuotationStart string = `(?U)(".*"|'.*')` // 获取引号中的内容,只匹配一次
QuotationEnd string = `"|'` // 匹配单或双引号
Variate string = `(?U)\$\{.*\}` // 匹配变量
YamlFlow string = `^\{.*\}`
)
var (
rxFirstSection = regexp.MustCompile(FirstSection)
rxSection = regexp.MustCompile(Section)
rxNode = regexp.MustCompile(Node)
rxSeparator = regexp.MustCompile(Separator)
rxQuotationStart = regexp.MustCompile(QuotationStart)
rxQuotationEnd = regexp.MustCompile(QuotationEnd)
rxVariate = regexp.MustCompile(Variate)
rxYamlFlow = regexp.MustCompile(YamlFlow)
)