Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8346237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:56:39+00:00 2026-06-09T06:56:39+00:00

I am looking for a regular expression to remove comment lines from a sql

  • 0

I am looking for a regular expression to remove comment lines from a sql fine. All of the comments start with “COMMENT ON” (obviously) but may tend to have more than one line. I was able to come up with an expression to remove a single line but am struggling with multiple lines. A typical entry I am looking to remove looks like this:

COMMENT ON TABLE account_heading IS $$
This table holds the account headings in the system.  Each account must belong 
to a heading, and a heading can belong to another heading.  In this way it is 
possible to nest accounts for reporting purposes.$$;

So what I need is a regular expression that follows multiple lines up to the point it sees a
semicolon.

I came up with this one that will search to the second line and stop at the double dollar ($$). I just started with RegEx yesterday so forgive me if this is absolutely completely wrong (which I am sure it is):

^COMMENT ([^\n\r]+)[\n\r]([\$;\n\r]+)

I am doing this in TextWrangler with the Grep option on a Mac.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T06:56:40+00:00Added an answer on June 9, 2026 at 6:56 am

    Well, I don’t know SQL very well, but if you want the content between the ‘$$’, just use:

    \${2}[^\${2}]*\${2};
    

    If you want everything after the ‘IS’ Word:

    COMMENT .*? IS ([^;]*)
    

    Matches anything that isn’t a semicolon (get the first group, not the match).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for a regular expression to split a field list from an SQL
I am looking for a single regular expression that will replace all replace me
Looking for a regular expression that match the following relative URLs: All urls starts
I was looking at the regular expression for validating various data types from the
I'm looking for a regular expression, but can't find. Parsing a text file looking
I'm trying to do remove JavaScript comments via a regular expression in C# and
I'm looking for a regular expression that removes illegal characters. But I don't know
I'm looking for a regular expression that will match all strings EXCEPT those that
Possible Duplicate: I'm looking for a regular expression to remove a given (x)HTML tag
I'm looking for a regular expression that can find the alpha representation of a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.