I am trying to find the string positions after the word “VALUES” in INSERT statement, this would be the position before the actual row data.
I know I need to use regular expression to pick up the pattern for INSERT statements and not use strpos to look for the word “VALUES”, but when is comes to regular expression functions I’m a bit of a novice.
UPDATED
I would like to find the position of “) VALUES (” and allowing whitespaces, \n, \r, \t etc between the parentheses as sometimes VALUES is on a new line.
Thanks
SQL file:
# ------------------------------
# --
# -- Dumping data for table `table_a`
# --
INSERT INTO `table_a` (`a`, `b`, `c`, `d`)
VALUES -- get position
(1, 'b', 'c', 'd'),
(2, 'b', 'c', 'd'),
(3, 'b', 'c', 'd');
# ------------------------------
# --
# -- Dumping data for table `table_b`
# --
INSERT INTO `table_b` (`a`, `b`, `c`, `d`) VALUES -- get position
(1, 'b', 'c', 'd'),
(2, 'b', 'c', 'd'),
(3, 'b', 'c', 'd');
This should do the trick: