我们的代码当中有很多很多如下的代码:@H_403_3@@H_403_3@
UarrMain[0] := AsMainType(edLayer,myStr,'Layer','结构层名称');@H_403_3@@H_403_3@
UarrMain[1] := AsMainType(edKind,'Kind','稳定剂种类');@H_403_3@@H_403_3@
UArrSub[0] := AsSubType(myInt,True,'seqnum','序号');@H_403_3@@H_403_3@
UArrSub[1] := AsSubType(myStr,False,'BoxNumber','试验盒号');@H_403_3@@H_403_3@
UArrSub[2] := AsSubType(myFloat,'BoxWeigth','盒的质量');
@H_403_3@@H_403_3@
.....
我现在需要提取第三个,第四个参数。@H_403_3@@H_403_3@
放上来,下次电脑坏就不用重新写了。工作当中用到的,可以减轻工作量。@H_403_3@
- packagemain@H_403_3@@H_403_3@
- import@H_403_3@
- (@H_403_3@
- "io"@H_403_3@@H_403_3@@H_403_3@
- "fmt"@H_403_3@@H_403_3@@H_403_3@
- "regexp"@H_403_3@@H_403_3@@H_403_3@
- "strings"@H_403_3@@H_403_3@@H_403_3@
- "net/http"@H_403_3@@H_403_3@@H_403_3@
- )@H_403_3@
- @H_403_3@
- const@H_403_3@(@H_403_3@@H_403_3@
- sql="EXECsys.sp_addextendedproperty@name=N'MS_Description',@value=N'AAAA',@level0type=N'SCHEMA',@level0name=N'dbo',@level1type=N'TABLE',@level1name=N'CCCC',@level2type=N'COLUMN',@level2name=N'BBBB'"@H_403_3@@H_403_3@@H_403_3@
- sql2="EXECsys.sp_addextendedproperty@name=N'MS_Description',@level1name=N'CCCC'"@H_403_3@@H_403_3@@H_403_3@
- html=@H_403_3@
- `<html>@H_403_3@
- <head><title>提取<a/title></head>@H_403_3@
- <body><formmethod='post'@H_403_3@>@H_403_3@@H_403_3@
- TableName:<inputtype="text"@H_403_3@name=@H_403_3@"tablename"@H_403_3@></input>qs_Table中的TableName,比如TestRecordC21<br></br>@H_403_3@@H_403_3@
- 表格名称:<inputtype="text"@H_403_3@name=@H_403_3@"tablename2"@H_403_3@></input>比如石料试验记录<br></br>@H_403_3@@H_403_3@
- <textarearows="20"@H_403_3@cols=@H_403_3@"120"@H_403_3@name=@H_403_3@"target"@H_403_3@></textarea><br></br>@H_403_3@@H_403_3@
- <inputtype="submit"@H_403_3@value=@H_403_3@"Submit"@H_403_3@></input>@H_403_3@@H_403_3@
- %s@H_403_3@
- </form>@H_403_3@
- </body>@H_403_3@
- </html>`@H_403_3@
- )@H_403_3@
- @H_403_3@
- funcmySearch(strstring)(resultstring){@H_403_3@
- result=""@H_403_3@@H_403_3@@H_403_3@
- regSub:=regexp.MustCompile(`(?i)AsSubType\s*\(\w+\s*\,\s*(True|False)\s*\,\s*\'\s*(\w+)\s*\'\s*\,\s*\'\s*(.*?)\s*\'@H_403_3@`)@H_403_3@@H_403_3@
- regMain:=regexp.MustCompile(`(?i)AsMainType\s*\(\w+\s*\,\s*(\w+)\s*\,\s*\'\s*(.*?)\s*\'@H_403_3@`)@H_403_3@@H_403_3@
- @H_403_3@
- resultSub:=regSub.FindAllStringSubmatch(str,-1)@H_403_3@
- resultMain:=regMain.FindAllStringSubmatch(str,-1)@H_403_3@
- @H_403_3@
- for@H_403_3@_,V:=rangeresultSub{@H_403_3@@H_403_3@
- result=result+strings.Replace(strings.Replace(sql,"AAAA"@H_403_3@,V[3],-1),@H_403_3@"BBBB"@H_403_3@,V[2],-1)+@H_403_3@@H_403_3@
- "<br></br>"@H_403_3@+@H_403_3@"GO"@H_403_3@+@H_403_3@"<br></br>"@H_403_3@@H_403_3@@H_403_3@
- }@H_403_3@
- @H_403_3@
- for@H_403_3@_,V:=rangeresultMain{@H_403_3@@H_403_3@
- result=result+strings.Replace(strings.Replace(sql,-1)+@H_403_3@@H_403_3@
- "<br></br>"@H_403_3@+@H_403_3@"GO"@H_403_3@+@H_403_3@"<br></br>"@H_403_3@@H_403_3@@H_403_3@
- }@H_403_3@
- @H_403_3@
- return@H_403_3@@H_403_3@@H_403_3@
- }@H_403_3@
- @H_403_3@
- funcAnalyze(whttp.ResponseWriter,r*http.Request){@H_403_3@
- if@H_403_3@r.Method==@H_403_3@"GET"@H_403_3@{@H_403_3@@H_403_3@
- io.WriteString(w,strings.Replace(html,"%s"@H_403_3@,@H_403_3@""@H_403_3@,-1))@H_403_3@@H_403_3@
- return@H_403_3@@H_403_3@@H_403_3@
- }@H_403_3@
- @H_403_3@
- if@H_403_3@r.Method==@H_403_3@"POST"@H_403_3@{@H_403_3@@H_403_3@
- str:=r.FormValue("target"@H_403_3@)@H_403_3@@H_403_3@
- tablename:=r.FormValue("tablename"@H_403_3@)@H_403_3@@H_403_3@
- tablename2:=r.FormValue("tablename2"@H_403_3@)@H_403_3@@H_403_3@
- if@H_403_3@tablename==@H_403_3@""@H_403_3@{@H_403_3@@H_403_3@
- io.WriteString(w,@H_403_3@"<divborder='1'>"@H_403_3@+@H_403_3@@H_403_3@
- "TableName没有填写"@H_403_3@+@H_403_3@"</div>"@H_403_3@,-1))@H_403_3@@H_403_3@
- return@H_403_3@@H_403_3@@H_403_3@
- }@H_403_3@
- if@H_403_3@tablename2==@H_403_3@""@H_403_3@{@H_403_3@@H_403_3@
- io.WriteString(w,@H_403_3@"<divborder='1'>"@H_403_3@+@H_403_3@@H_403_3@
- "表格名称没有填写"@H_403_3@+@H_403_3@"</div>"@H_403_3@,-1))@H_403_3@@H_403_3@
- return@H_403_3@@H_403_3@@H_403_3@
- }@H_403_3@
- if@H_403_3@str==@H_403_3@""@H_403_3@{@H_403_3@@H_403_3@
- io.WriteString(w,@H_403_3@"<divborder='1'>"@H_403_3@+@H_403_3@@H_403_3@
- "查找内容没有填写"@H_403_3@+@H_403_3@"</div>"@H_403_3@,-1))@H_403_3@@H_403_3@
- return@H_403_3@@H_403_3@@H_403_3@
- }@H_403_3@
- @H_403_3@
- sqlCMD:=strings.Replace(html,@H_403_3@"<divborder='1'>"@H_403_3@+@H_403_3@@H_403_3@
- strings.Replace(mySearch(str),"CCCC"@H_403_3@,tablename,-1)+@H_403_3@"</div>"@H_403_3@,-1)@H_403_3@@H_403_3@
- sqlCMD=sqlCMD+strings.Replace(strings.Replace(sql2,tablename2,@H_403_3@"CCCC"@H_403_3@,-1)@H_403_3@@H_403_3@
- io.WriteString(w,sqlCMD)@H_403_3@
- }@H_403_3@
- }@H_403_3@
- @H_403_3@
- funcmain(){@H_403_3@
- fmt.Println("Openhttp://localhost:8888/extract"@H_403_3@)@H_403_3@@H_403_3@
- http.HandleFunc("/extract"@H_403_3@,Analyze)@H_403_3@@H_403_3@
- err:=http.ListenAndServe(":8888"@H_403_3@,nil)@H_403_3@@H_403_3@
- if@H_403_3@err!=nil{@H_403_3@@H_403_3@
- fmt.Println(err.Error())@H_403_3@
- }@H_403_3@
- }@H_403_3@