let s = "Cannot add or update a child row: a foreign key constraint fails (`testdb`.`products`, CONSTRAINT `products_ibfk_3` FOREIGN KEY (`category_id`) REFERENCES `product_categories` (`id`))"
在这里,我需要提取带有括号ex.extracted = "category_id"
的文本中的FOREIGN键。我不知道该怎么办CCD_ 2。
有人能帮我吗?
提前感谢您对社区的大力支持。
let s = "Cannot add or update a child row: a foreign key constraint fails (`testdb`.`products`, CONSTRAINT `products_ibfk_3` FOREIGN KEY (`category_id`) REFERENCES `product_categories` (`id`))";
let match = /FOREIGN KEY (`([w]*)`)/.exec(s);
let extracted = match[1];
console.log(extracted);
编辑:
模式(/FOREIGN KEY (([w]*))/
(确实提取";FOREING KEY(category_id(";以及";category_ id";来自字符串。请参考此网址。