REGEXP pattern to find -- between a ; and end of line

Could someone type the Regular Expression to
find sql comment after end of sql statement?

I need to find and instance of
--
between a ; and the end of a line.

This causes errors when scripts are run using SQLPLUS.

Thanks,

Geoff
gswitzAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
QlemoConnect With a Mentor DeveloperCommented:
The filter condition is
    (.*;)\s*--
Group 0 should result in the command without comment after semicolon.
This is the most simple expression; with some effort we can create a filter generating the SQL commands without comments (and other stuff appended after semicolon, which is not working with SqlPlus).
0
 
gswitzAuthor Commented:
Thanks!
0
 
JPrzybyszewskiCommented:
Hi

I have prepared the test case for you and the solution. My example code was:

CREATE OR REPLACE PROCEDURE callme (a NUMBER, b NUMBER) IS
BEGIN
NULL;
NULL; -- This is the comment
dbms_output.put_line('---; ---;---'); -- This is the comment that I want to remove
END;

And I wanted to remove the comments that you can see above - only in two lines. I have used VI to get edit the file with the script. The Regexp that handles it correctly is below.

%s/;\s*--\([^;]*\)\{1\}$/;/

Regards,
Jarek
0
All Courses

From novice to tech pro — start learning today.