0

I'm having a file in which there are lines containing some patterns as

`XX3 DB3 DBB1 VDD VSS VSSS VDDS inverter params: ln=.045u wn=0.5 mm=mm'

`XX4 DBB1 DB3 VDD VSS VSSS VDDS inverter params: ln=.045u wn=.12u

`XX14 DBB1 DB_TBY VDD VSS VSSS VDDS inverter params: Mpar =(Something))

I need to replace these lines as

`XX3 DB3 DBB1 VDD VSS VSSS VDDS inverter

`XX4 DBB1 DB3 VDD VSS VSSS VDDS inverter

`XX14 DBB1 DB_TBY VDD VSS VSSS VDDS inverter

that is I want to delete everything after params, It can be anything, till the newline.

    foreach(@lines){
     $_ =~ s/params: .*?[a-z,A-Z,),0-9,mm,m]'/ /g;}

But here everything is deleting but it should end with ' . As I have no idea about what all patterns can be present , this technique is not possible.

2 Answers2

2

Looks like your regex is too complicated (and, therefore, too likely to be wrong). If you want to delete everything after params: then just do that.

for (@lines) {
  s/params:.+//;
  ...
}
Dave Cross
  • 68,119
  • 3
  • 51
  • 97
1

If you want to keep the single quote at the end, do:

for (@lines) {
  s/params:.+/'/;
  ...
}
Toto
  • 89,455
  • 62
  • 89
  • 125