Home > Blockchain >  Regex - find lines starting with 2 dashes containing single speech mark
Regex - find lines starting with 2 dashes containing single speech mark

Time:09-08

Starting with this sample text:

-- Search for relevant Title, second half of the screen, under "Context Field Values" lists the main parts of the Flexfield
-- This lists the bits users see in Core Applications when they click into the DFF plus shows if there is a LOV linked to the field
-- It's a test
-- So is this

      SELECT fat.application_name
           , fdfv.title
           , fdfv.application_table_name

How can I use a RegEx in Notepad to find any lines starting with -- and containing a single speech mark '?, so that only this line is returned:

-- It's a test

I tried a silly amount of things, such as:

  • [^--']
  • [^--*']
  • [*--*']
  • --[']
  • [--][']
  • [']
  • ^--[']
  • ^--*\'*
  • ^--*'*

But as you can see, I'm not too clever!

CodePudding user response:

You may use this regex to match a line starting with -- containing only a single ':

^\s*--[^'\r\n]*'[^'\r\n]*$

Make sure to keep MULTILINE mode on since we are using anchor ^.

enter image description here

  • Related