simonsteele / pn

Programmer's Notepad
374 stars 116 forks source link

Regexp matching finds not all occurences #189

Closed Thomassso closed 5 years ago

Thomassso commented 5 years ago

Regexp matching works not correcty:

  1. does not find all occurences
  2. fails to recognize the group correctly

Test case step by step:

  1. I opened some existing files.

  2. I created a new tab.

  3. I pasted the following text

    "CICA_BI_CURSOR" DATE,
    "D_POLICYNUMBER" VARCHAR2(90 CHAR),
    "D_SECONDARYPOLICYNUMBER" VARCHAR2(90 CHAR),
    "D_SEQUENCERNUMBER" VARCHAR2(90 CHAR),
    "D_SOURCEPRODUCTCLASS" VARCHAR2(90 CHAR),
    "D_SOURCEPRODUCT" VARCHAR2(90 CHAR),
    "D_ENTITYSUBTYPE" VARCHAR2(90 CHAR),
    "POLICYVERSIONIDX" NUMBER(4,0),
    "D_VERSIONNUMBER" NUMBER(9,0),
    "D_ISACTIVE" VARCHAR2(90 CHAR),
    "D_ACTION" VARCHAR2(90 CHAR),
    "D_PAYMENTFREQUENCY" VARCHAR2(90 CHAR),
    "D_PAYMENTMETHOD" VARCHAR2(90 CHAR),
    "D_PROCESSBYNAME" VARCHAR2(90 CHAR),
    "D_CREATEDBYNAME" VARCHAR2(90 CHAR),
    "D_STATUS" VARCHAR2(90 CHAR),
    "D_ACTIVATIONMETHOD" VARCHAR2(90 CHAR),
    "D_SCOPECONTRACTNUMBER" VARCHAR2(90 CHAR),
    "D_RENEWALTYPE" VARCHAR2(90 CHAR),
    "D_BUSINESSSOURCE" VARCHAR2(90 CHAR),
    "D_CONTACTMETHOD" VARCHAR2(10 CHAR),
    "DD_BUSINESSFROM" DATE,
    "DD_BUSINESSFROMYEAR" NUMBER(4,0),
    "DD_BUSINESSFROMMONTH" NUMBER(2,0),
    "DD_BUSINESSTO" DATE,
    "DD_BUSINESSTOYEAR" NUMBER(4,0),
    "DD_BUSINESSTOMONTH" NUMBER(2,0),
    "DD_CREATIONDATE" DATE,
    "DD_CREATIONDATEYEAR" NUMBER(4,0),
    "DD_CREATIONDATEMONTH" NUMBER(2,0),
    "DD_PROCESSDATE" DATE,
    "DD_PROCESSDATEYEAR" NUMBER(4,0),
    "DD_PROCESSDATEMONTH" NUMBER(2,0),
    "DD_INFORCEDATE" DATE,
    "DD_INFORCEDATEYEAR" NUMBER(4,0),
    "DD_INFORCEDATEMONTH" NUMBER(2,0),
    "DD_ISSUEDATE" DATE,
    "DD_ISSUEDATEYEAR" NUMBER(4,0),
    "DD_ISSUEDATEMONTH" NUMBER(2,0),
    "DD_POLICYSTARTDATE" DATE,
    "DD_POLICYSTARTDATEYEAR" NUMBER(4,0),
    "DD_POLICYSTARTDATEMONTH" NUMBER(2,0),
    "DD_POLICYENDDATE" DATE,
    "DD_POLICYENDDATEYEAR" NUMBER(4,0),
    "DD_POLICYENDDATEMONTH" NUMBER(2,0),
    "DD_PAIDTO" DATE,
    "DD_PAIDTOYEAR" NUMBER(4,0),
    "DD_PAIDTOMONTH" NUMBER(2,0),
    "CANCELLATIONIDX" NUMBER(4,0),
    "D_CANCELLATIONREASON" VARCHAR2(90 CHAR),
    "D_CANCELLATIONNUMBER" VARCHAR2(90 CHAR),
    "D_CANCELLEDBY" VARCHAR2(90 CHAR),
    "DD_NOTICEOFCANCELLATIONDATE" DATE,
    "DD_CANCELLATIONDATE" DATE,
    "DD_TERMINATIONGENERATIONDATE" DATE,
    "D_BROKERSCOUNT" NUMBER(9,0),
    "D_BROKEREMPLOYEENAME0" VARCHAR2(90 CHAR),
    "D_BROKEREMPLOYEEID0" VARCHAR2(90 CHAR),
    "D_BROKEREMPLOYEEREFERENCENUMB0" VARCHAR2(90 CHAR),
    "D_BROKERSHAREONPOLICY0" VARCHAR2(90 CHAR),
    "D_BROKERNEWBUSINESSCOMMISSION0" VARCHAR2(90 CHAR),
    "D_BROKERRENEWALCOMMISSION0" VARCHAR2(90 CHAR),
    "D_BROKERNAME0" VARCHAR2(90 CHAR),
    "D_BROKERCODE0" VARCHAR2(90 CHAR),
    "D_BROKERREFERENCENUMBER0" VARCHAR2(90 CHAR),
    "D_BROKERGMB0" VARCHAR2(90 CHAR),
    "D_BROKERGMBNAME0" VARCHAR2(90 CHAR),
    "D_BROKEREMPLOYEENAME1" VARCHAR2(90 CHAR),
    "D_BROKEREMPLOYEEID1" VARCHAR2(90 CHAR),
    "D_BROKEREMPLOYEEREFERENCENUM1" VARCHAR2(90 CHAR),
    "D_BROKERSHAREONPOLICY1" VARCHAR2(90 CHAR),
    "D_BROKERNEWBUSINESSCOMMISSION1" VARCHAR2(90 CHAR),
    "D_BROKERRENEWALCOMMISSION1" VARCHAR2(90 CHAR),
    "D_BROKERNAME1" VARCHAR2(90 CHAR),
    "D_BROKERCODE1" VARCHAR2(90 CHAR),
    "D_BROKERREFERENCENUMBER1" VARCHAR2(90 CHAR),
    "D_BROKERGMB1" VARCHAR2(90 CHAR),
    "D_BROKERGMBNAME1" VARCHAR2(90 CHAR),
    "D_TAXATOREMPLOYEENAME" VARCHAR2(90 CHAR),
    "D_TAXATOREMPLREFERENCENUMBER" VARCHAR2(90 CHAR),
    "D_POLICYHOLDERTYPEOFCONTACT" VARCHAR2(90 CHAR),
    "D_POLICYHOLDERPREFFIX" VARCHAR2(90 CHAR),
    "D_POLICYHOLDERSUFFIX" VARCHAR2(90 CHAR),
    "D_POLICYHOLDERCODE" VARCHAR2(90 CHAR),
    "D_POLICYHOLDERCOMPANYEMPLNAME" VARCHAR2(90 CHAR),
    "D_POLICYHOLDERCOMPANYEMPFNAME" VARCHAR2(90 CHAR),
    "D_POLICYHOLDERLEGALFORM" VARCHAR2(90 CHAR),
    "D_POLICYHOLDERREGNUMBER" VARCHAR2(90 CHAR),
    "D_POLICYHOLDERCOMPANYNAME" VARCHAR2(90 CHAR),
    "D_POLICYHOLDERLASTNAME" VARCHAR2(90 CHAR),
    "D_POLICYHOLDERFIRSTNAME" VARCHAR2(90 CHAR),
    "D_POLICYHOLDERID" VARCHAR2(90 CHAR),
    "D_POLICYHOLDERDATEOFBIRTH" DATE,
    "ADDRESSESCOUNT" NUMBER(9,0),
    "PRIMARYADDRESSIDX" NUMBER(4,0),
    "D_PRIMARYADDRESSADDRESS1" VARCHAR2(90 CHAR),
    "D_PRIMARYADDRESSADDRESS2" VARCHAR2(90 CHAR),
    "D_PRIMARYADDRESSCITY" VARCHAR2(90 CHAR),
    "D_PRIMARYADDRESSPOSTCODE" VARCHAR2(90 CHAR),
    "D_PRIMARYADDRESSCOUNTRY" VARCHAR2(90 CHAR),
    "D_PRIMARYADDRESSADDRESSTYPE" VARCHAR2(90 CHAR),
    "OTHERADDRESSIDX" NUMBER(4,0),
    "D_OTHERADDRESSADDRESS1" VARCHAR2(90 CHAR),
    "D_OTHERADDRESSADDRESS2" VARCHAR2(90 CHAR),
    "D_OTHERADDRESSCITY" VARCHAR2(90 CHAR),
    "D_OTHERADDRESSPOSTCODE" VARCHAR2(90 CHAR),
    "D_OTHERADDRESSCOUNTRY" VARCHAR2(90 CHAR),
    "D_OTHERADDRESSADDRESSTYPE" VARCHAR2(90 CHAR),
    "D_EMAIL" VARCHAR2(90 CHAR),
    "D_PHONE" VARCHAR2(90 CHAR),
    "D_MOBILEPHONE" VARCHAR2(90 CHAR),
    "MAINBUSINESSCLASSIDX" NUMBER(4,0),
    "D_INSUREDSUBJECTREGNPLATENUM" VARCHAR2(90 CHAR),
    "D_INSUREDSUBJECTREGPLATETYPE" VARCHAR2(90 CHAR),
    "D_INSUREDSUBJECTREGTYPE" VARCHAR2(90 CHAR),
    "D_INSUREDSUBJECTREGDOCUMENTNUM" VARCHAR2(90 CHAR),
    "D_INSUREDSUBJECTINDIVIDIMPORT" VARCHAR2(90 CHAR),
    "DD_INSUREDSUBJECTFIRSTREGDATE" DATE,
    "D_INSUREDSUBJECTVIN" VARCHAR2(90 CHAR),
    "D_INSUREDSUBJECTVEHICLETYPE" VARCHAR2(90 CHAR),
    "D_INSUREDSUBJECTUSAGE" VARCHAR2(90 CHAR),
    "D_INSUREDSUBJECTBRAND" VARCHAR2(90 CHAR),
    "D_INSUREDSUBJECTMODEL" VARCHAR2(90 CHAR),
    "D_INSUREDSUBJECTENGINEKW" VARCHAR2(90 CHAR),
    "D_INSUREDSUBJECTFUEL" VARCHAR2(90 CHAR),
    "D_INSUREDSUBJECTENGINECCM" VARCHAR2(90 CHAR),
    "D_INSUREDSUBJECTTOTALWEIGHT" VARCHAR2(90 CHAR),
    "D_INSUREDSUBJECTSEATS" VARCHAR2(90 CHAR),
    "D_INSUREDSUBJECTSECURITY" VARCHAR2(90 CHAR),
    "D_INSUREDSUBJECTLEASING" VARCHAR2(90 CHAR),
    "D_INSUREDSUBJECTFIRSTOWNER" VARCHAR2(90 CHAR),
    "D_INSUREDSUBJECTSUMINSURED" NUMBER(16,4),
    "MTPLBUSINESSCLASSIDX" NUMBER(4,0),
    "D_MTPLCLAIMSREGISTERED" NUMBER(9,0),
    "D_MTPLCLAIMSREGISTERED24M" NUMBER(9,0),
    "D_MTPLSIGNIFICANTPERIOD" NUMBER(9,0),
    "D_MTPLBONUSMALUS" NUMBER(20,0),
    "CASCOBUSINESSCLASSIDX" NUMBER(4,0),
    "D_CASCOVINCULATION" VARCHAR2(90 CHAR),
    "D_CASCOVEHICLEORIGIN" VARCHAR2(90 CHAR),
    "D_CASCOOWNERBENEFICIAL" VARCHAR2(90 CHAR),
    "D_CASCOOTHERPERSONID" VARCHAR2(90 CHAR),
    "D_CASCOOTHERPERSONNAME" VARCHAR2(90 CHAR),
    "D_CASCOMILEAGE" NUMBER(9,0),
    "D_CASCOCLAIMSREGISTERED" NUMBER(9,0),
    "D_CASCOCLAIMSREGISTERED24M" NUMBER(9,0),
    "D_CASCOSIGNIFICANTPERIOD" NUMBER(9,0),
    "D_CASCOBONUSMALUS" NUMBER(20,0),
    "BUSINESSCLASSIDX" NUMBER(4,0),
    "D_PRODUCTCLASS" VARCHAR2(90 CHAR),
    "D_LIMIT" VARCHAR2(90 CHAR),
    "D_EXCESS" VARCHAR2(90 CHAR),
    "RISKIDX" NUMBER(4,0),
    "D_RISKNAME" VARCHAR2(90 CHAR),
    "D_APPLIEDDISCOUNTSCOUNT" NUMBER(9,0),
    "M_ANNUALPREMIUMVALUE" NUMBER(16,4),
    "M_ANNUALPREMIUMWITHDISCOUNTS" NUMBER(16,4),
    "M_PAYABLEPREMIUMVALUE" NUMBER(16,4),
    "M_TERMPAYABLECORRECTIONVALUE" NUMBER(16,4),
    "M_TERMPAYABLEPREMIUMVALUE" NUMBER(16,4),
    "D_APPLIEDDISCOUNTSID0" VARCHAR2(90 CHAR),
    "D_APPLIEDDISCOUNTS0" VARCHAR2(90 CHAR),
    "M_APPLIEDDISCOUNTSAMOUNT0" NUMBER(16,4),
    "M_APPLIEDDISCOUNTSTERMAMOUNT0" NUMBER(16,4),
    "D_APPLIEDDISCOUNTSID1" VARCHAR2(90 CHAR),
    "D_APPLIEDDISCOUNTS1" VARCHAR2(90 CHAR),
    "M_APPLIEDDISCOUNTSAMOUNT1" NUMBER(16,4),
    "M_APPLIEDDISCOUNTSTERMAMOUNT" NUMBER(16,4),
    "D_APPLIEDDISCOUNTSID2" VARCHAR2(90 CHAR),
    "D_APPLIEDDISCOUNTS2" VARCHAR2(90 CHAR),
    "M_APPLIEDDISCOUNTSAMOUNT2" NUMBER(16,4),
    "M_APPLIEDDISCOUNTSTERMAMOUNT2" NUMBER(16,4),
    "D_APPLIEDDISCOUNTSID3" VARCHAR2(90 CHAR),
    "D_APPLIEDDISCOUNTS3" VARCHAR2(90 CHAR),
    "M_APPLIEDDISCOUNTSAMOUNT3" NUMBER(16,4),
    "M_APPLIEDDISCOUNTSTERMAMOUNT3" NUMBER(16,4),
    "D_APPLIEDDISCOUNTSID4" VARCHAR2(90 CHAR),
    "D_APPLIEDDISCOUNTS4" VARCHAR2(90 CHAR),
    "M_APPLIEDDISCOUNTSAMOUNT4" NUMBER(16,4),
    "M_APPLIEDDISCOUNTSTERMAMOUNT4" NUMBER(16,4),
  4. Started replace all with the following settings

    find what: ^"(.*[^"])".*,$
    replace with: create index hr_pvzp_policy_idx_1 on hr.pvzp_policy ("\1");
    regexp: enabled
    match case: enabled
    allow backslash: enabled
  5. Only half of row count were replaced, the rest lost and the replaced string is also different than it should be. EXAMPLE from the output:

    create index hr_pvzp_policy_idx_1 on hr.pvzp_policy ("CICA_BI_CURSOR" DATE,
    ");
    create index hr_pvzp_policy_idx_1 on hr.pvzp_policy ("D_SECONDARYPOLICYNUMBER" VARCHAR2(90 CHAR),
    ");
    create index hr_pvzp_policy_idx_1 on hr.pvzp_policy ("D_SOURCEPRODUCTCLASS" VARCHAR2(90 CHAR),
    ");

    The CORRECT output should be:

    create index hr_pvzp_policy_idx_1 on hr.pvzp_policy ("CICA_BI_CURSOR");
    create index hr_pvzp_policy_idx_1 on hr.pvzp_policy ("D_POLICYNUMBER");
    create index hr_pvzp_policy_idx_1 on hr.pvzp_policy ("D_SECONDARYPOLICYNUMBER");
Thomassso commented 5 years ago

I figured out, this isn't a bug. The used regexp expression is incorrect. This one ^"(.*)".*,$ will do the job as expected.