Hello all,
I have generated a sql command that appears as follows:
$s = "INSERT INTO temp_table (uid, value) VALUES ( 'mondo_user', 12),
( 'mondo_user', 14), ( 'mondo_user', 9), ( 'other_user', 14),
( 'mondo_user', Submit),";
The string is generated automatically, but in the process of my algorithms, the final
, ( 'mondo_user', Submit),
string needs to come out. As you can see, I can't just count back a fixed number of spaces, as the user name can change, as does the number of record entries.
I am looking for the regex command that will truncate the final parenthetical set of values, along with the commas before and after it so that it becomes a legitimate SQL statement. Can regex work backwards?
Do you have any guidance? I've been looking through tutorials and cannot come to terms with this. Thanks.