PEC to CEP a RegEX method to convert codes.

Discussion in 'Xebra/Arbex Discussion' started by noabody, Jun 16, 2017.

  1. noabody

    noabody New Member

    Messages:
    3
    Likes Received:
    0
    Notepad++ regex replacement method to convert PEC codelist for use in CEP. Needs automation.
    PEC codelist.ini downloaded from http://psxdatacenter.com/downloads.html with most recent version dated 28-May-2014

    Matches any line that begins with a dot. ^[.](.*) OR |
    any line not starting with # or . or ; and not having 13 or more hex characters including spaces (code line). These are lines of code that don't follow proper code format. ^(?!["#.;])(?![[:xdigit:][:s:]]{13,})(.*) OR |
    any line with 9 or more hex with a space. ^(?!["#.;])([[:xdigit:]]{9,})(\s{1,})(.*)

    Replace with empty to truncate the bogus code.

    Find:
    Code:
    ^[.](.*)|^(?!["#.;])(?![[:xdigit:][:s:]]{13,})(.*)|^(?!["#.;])([[:xdigit:]]{9,})(\s{1,})(.*)
    Matches any line that begins with a " but is not followed by code. Replace with empty.

    Find:
    Code:
    (^".*)\r\n(?![[:xdigit:][:s:]]{13,})
    Matches two or more vertical whitespace lines that are not preceded by a word. Replace with empty to clean out excess CR\LF.

    Find:
    Code:
    ^(?!\w)\v{2,}
    Matches a code line that has exactly 8 codes followed by four codes with no interim space. Replace to add the space. Code cleanup. Wasn't needed in my example.

    Find:
    Code:
     ^(?!["#.;])([[:xdigit:]]{8})([[:xdigit:]]{4})
    Replace:
    Code:
     \1 \2
    Matches a line with 4 hex and a space. Truncates the space. Code aberration cleanup.

    Find:
    Code:
    ^(?!["#.;])([[:xdigit:]]{4})(\s{1,})(.*)
    Replace:
    Code:
    \1\3
    Matches any # followed by a capital s when the search is case-sensitive. Should be replaced with a space.

    Find:
    Code:
    #(?=S)
    Matches any line starting with ". These are text headings and should be preceded with a CR\LF and followed by a ". Text formatting.

    Find:
    Code:
    (^".*\S)
    Replace:
    Code:
    \r\n\1(")
    Matches any line beginning with a # and adds text formatting before and after which is consistent with CEP.

    Find:
    Code:
    (^#)(.*)
    Replace:
    Code:
    \r\n(.end)\r\n\r\n(#----------------------------------------------------------------------------)\r\n(#new 28/5/14)\r\n(")\2(")
    All the RegEx expressions are listed in order of precedence. They should be operated in that sequence.

    Finally, I manually fixed the header and footer by replacing the standard PEC heading in codelist.ini with the one found in CEP codelist.txt and moved the topmost .end to the bottom of the document.

    CEP blissfully read the file and offered the relevant cheats.
    Last edited: Jun 16, 2017
  2. NGEmu.com Advertisement

Share This Page