The use and golang regular expression

I want to achieve the effect of
the following

[江苏省(320000)|PROV|0|][苏州市(320500)|CITY|0|][吴江区(320509)|AREA|0|][双板桥路()|ROAD|1|52号$]附近

Convert:

江苏省苏州市吴江区双板桥路52号附近

Here is the correct code for golang

reg := regexp.MustCompile("\\[([^\\(]+)\\(\\d*\\)\\|\\w*\\|\\d\\|([^\\]\\$]*)\\$?\\]")
fmt.Println(dis.Address)
dis.Address = reg.ReplaceAllString(dis.Address, "$1$2")
fmt.Println(dis.Address)

The following code is the same effect and grammar, syntax, and the main difference in regexbuddy golang of: a plurality escape character to \

\[([^\(]+)\(\d*\)\|\w*\|\d\|([^\]\$]*)\$?\]

Summarized as follows

  1. Normal expression \ w is able to identify the Chinese, but does not seem to be golang, need [\ u4e00- \ u9fa5] specified display
  2. golang use the escape character \\
  3. \ W \ d but also with other commonly represented \\ w \\ d
  4. regexp.MustCompile ( ``) to try such an approach remains to be

Guess you like

Origin www.cnblogs.com/nickchou/p/12556306.html