Answer the question
In order to leave comments, you need to log in
Extracting value between two "anchors"?
Hello veterans of the regex wars, is there a way to extract values by two conditional "anchors" using a regular expression. But if there are ideas on how to read SQL statements from a file in a node differently, without using regular expressions, I will wait for ideas.
The very source of trouble
-- START
CREATE DATABASE IF NOT EXISTS feather_store_dev;
-- END
-- START
CREATE TABLE IF NOT EXISTS feather_store_dev.accounts (
id int,
email varchar(25),
bio varchar(18),
password varchar(32),
PRIMARY KEY (id)
);
-- END
Answer the question
In order to leave comments, you need to log in
/\-\-\sSTART\n(.+?)\n\-\-\sEND/gs
https://regex101.com/r/nimXOU/2
Or the js option:
/\-\-\sSTART\n([\s\S]+?)\n\-\-\sEND/g
https://jsfiddle.net/54zknmag/
But if you just need to restore the database from a file, it's better with the help of SOURCE
https://www.mysqltutorial. org/mysql-administration...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question