0

I have lot of queries like this:

create table results
(
  id bigint,
  order_id bigint,
  article_id bigint default 0 ,
  check_id bigint,
  status text(1),
  total_units bigint,
  units_checked bigint,
  endtime bigint default 0,
  tenantid text(5),
  
  PRIMARY KEY (id,check_id,order_id, article_id, (tenantid,order_id,article_id,check_id))
--  constraint results_id_pk primary key (id),
--  constraint results_check_id_fk foreign key (check_id) references checks (id),
--  constraint results_order_id_fk foreign key (order_id) references orders (id),
--  constraint results_article_id_fk foreign key (article_id) references articles (id),
--  unique(tenantid,order_id,article_id,check_id)
  );

I would like to delete all lines starts with '--'.

I tried a variety of queries as suggested in this question:

^[-].*
^(-).*\r\n
^(\s)*(-).*(\r\n|\r|\n)?

Unfortunately, none of these work for me.

Josiah Yoder
  • 3,321
  • 4
  • 40
  • 58
Sun
  • 3,444
  • 7
  • 53
  • 83
  • 1
    Did you try `^--.*`? Or `^--.*\R?`? Surely `^[#;].*` will not work because you need to remove lines that start with `--`, not `#` or `;`. – Wiktor Stribiżew Jan 11 '18 at 09:55
  • Use the find all with - - and replace with a space. Would that not work? – Scott Chambers Jan 11 '18 at 09:55
  • Thanks @WiktorStribiżew, It's working with `^--.*` – Sun Jan 11 '18 at 11:43
  • The question that this is considered a duplicate of does NOT answer this novice enthusiast's question. That answer only explains how to find lines beginning with one character. The OP wants TWO characters at the start of the line. Yes, I know, how hard is it to duplicate a character in a regexp? But we are talking about a different question here. – Josiah Yoder Feb 04 '23 at 17:58

2 Answers2

1

Try with \n followed by -- and match any character after it

\n--.*
StefansArya
  • 2,802
  • 3
  • 24
  • 25
0

^[#;].* : Says remove lines starting with # or ;

You need to remove lines starting with -- so please try ^--.*

nbirla
  • 600
  • 3
  • 14