40 lines
1.5 KiB
Go
40 lines
1.5 KiB
Go
package main
|
||
|
||
import (
|
||
"fmt"
|
||
"regexp"
|
||
"testing"
|
||
)
|
||
|
||
func TestA(t *testing.T) {
|
||
main3()
|
||
}
|
||
func main3() {
|
||
ddl := `CREATE TABLE fs_guest (
|
||
guest_id bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
|
||
auth_key varchar(512) NOT NULL DEFAULT '' COMMENT 'jwt token',
|
||
status tinyint(3) unsigned DEFAULT '1' COMMENT '1正常 0不正常',
|
||
is_del tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否删除 1删除',
|
||
created_at int(11) NOT NULL DEFAULT '0' COMMENT '添加时间',
|
||
updated_at int(11) NOT NULL DEFAULT '0' COMMENT '更新时间',
|
||
is_open_render tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否打开个性化渲染(1:开启,0:关闭)',
|
||
is_thousand_face tinyint(1) NOT NULL DEFAULT '0' COMMENT '是否已经存在千人千面(1:存在,0:不存在)',
|
||
is_low_rendering tinyint(1) unsigned zerofill NOT NULL DEFAULT '0' COMMENT '是否开启低渲染模型渲染',
|
||
is_remove_bg tinyint(1) NOT NULL DEFAULT '1' COMMENT '用户上传logo是否去除背景',
|
||
guid decimal(10,2) NOT NULL,
|
||
PRIMARY KEY (guest_id) USING BTREE,
|
||
UNIQUE KEY fs_guest_guid_IDX (guid) USING BTREE,
|
||
KEY fs_guest_is_del_IDX (is_del) USING BTREE,
|
||
KEY fs_guest_status_IDX (status) USING BTREE,
|
||
KEY fs_guest_created_at_IDX (created_at) USING BTREE
|
||
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT COMMENT='游客表'`
|
||
|
||
// 正则表达式匹配
|
||
r, _ := regexp.Compile(`CREATE TABLE (\S+) \..*COMMENT='(.*)'`)
|
||
matches := r.FindStringSubmatch(ddl)
|
||
|
||
// 输出结果
|
||
fmt.Println("表名:", matches[1])
|
||
fmt.Println("注释:", matches[2])
|
||
}
|