gpt4 book ai didi

javascript - (My)SQL 上的正则表达式创建语句

转载 作者:行者123 更新时间:2023-11-30 23:34:02 24 4
gpt4 key购买 nike

I am using an older version of a tool I like and am familiar using, but it's not creating the right output in its create statement. Because this is going to be a repetitive task, I am making a little web tool; making my target Regex in JaveScript. I am looking to break up the replacements in a few bits, but I think 1 line of regex will get me going, I can then work backwards.

我想替换 '(' 之后的第一个 'BINARY(16)' 就在 Batch(或任何单词)之后. 我正在 RegexBuddy 中测试,我试过: \(\s\w+\s(BINARY\(\d{1,2}\)[^,)]) 以及许多其他东西, 但没有成功。

CREATE TABLE Batch(
batch_id BINARY(16) NOT NULL,
batch_datetime DATETIME,
overhead_project_id BINARY(16) NOT NULL,
PRIMARY KEY (batch_id)
)ENGINE=INNODB;

使用 ConvertMe.replace(/(FooStatement/gi, "INT(11) NOT NULL AUTO INCREMENT");。我的最终目标是:(我还必须在其他创建语句上修复一些 FLOAT 和其他 INT)

CREATE TABLE Batch(
batch_id INT(11) NOT NULL AUTO INCREMENT,
batch_datetime DATETIME,
overhead_project_id INT(11) NOT NULL,
PRIMARY KEY (batch_id)
)ENGINE=INNODB;

解决方案:ConvertMe = ConvertMe.replace(/(((\s|\n|\r)\w\s+)(BINARY(\d{1,2})[^, ]*)/gi, "$1INT(11) NOT NULL AUTO INCREMENT");

最佳答案

试试这个..我想这就是你要找的

\(?[A-Za-z].+?(BINARY\([0-9]{1,2}\))

关于javascript - (My)SQL 上的正则表达式创建语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9038638/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com