FunctionList.xml how to ignore wrong syntax.



  • i’ve been making new parser for my logfile.
    but i couldn’t find out a way how to ignore wrong syntax.

    for example,

    [SECTION] part1 {
    SECTION 2018-03-22 THU 13:14:23
    BLA BLA 1234 : DENY
      logloglog

    }

    [SECTION] part2 {
    SECTION 2018-03-22 THU 13:16:23
    BLA BLA 1234 : COMPLD
      logloglog
    }

    [SECTION] part3 {
      logloglog
    SECTION 2018-03-22 THU 13:18:23
    BLA BLA 1234 : DENY
      logloglog

    }

    [SECTION] part4 {
    SECTION 2018-03-22 THU 13:20:23
    }

    [SECTION] part5 {
    }

    [SECTION] part6 {
      logloglog
    SECTION 2018-03-22 THU 13:25:23
    BLA BLA 1234 : COMPLD
      logloglog
    }

    [SECTION] part7 {

    SECTION 2018-03-22 THU 13:30:23
    BLA BLA 1234 : COMPLD
    

    }

    i wand to match part2, part6,part7 by RE.
    (i use prompt name(=SECTION) and date,time and ‘COMPLD’ word.)

    i tested RE at https://regex101.com/

    (?x)
    (?ms)
    ^(?:[(.+)]\s+) part[0-9]+\s{
    \s+
    .?                       # after founding out issue about part6. i added here
    (?:\1)\s+[0-9]{4}-[0-9]{2}-[0-9]{2}\s+(?:SUN|MON|TUE|WED|THU|FRI|SAT)\s+[0-9]{2}:[0-9]{2}:[0-9]{2}
    \s+
    [A-Z0-9]
    \s+:\s+COMPLD
    .*?                       # after founding out issue about part6. i added here
    \s+
    }

    but, i had a problem with ‘part6’.
    so i added ‘.*?’ in the middle.

    however, i think ‘.*?’ is not correct RE

    please, help me to solve this issue.



  • Try this:

    (?x)
    (?ms)
    ^[(\w+)]\s+part\d+\s+\{
    [^}]*?
    \1\s+\d{4}-\d{2}-\d{2}\s+(?:SUN|MON|TUE|WED|THU|FRI|SAT)\s+\d{2}:\d{2}:\d{2}
    [^:]+?\s+:\s+COMPLD
    [^}]*?
    \}
    


  • thanks for your help.
    i works well~ :)


Log in to reply