• Parsing MT940 SWIFT Message using Java REGEX

    From smurugavelmsc@gmail.com@21:1/5 to John B. Matthews on Tue Oct 18 05:41:31 2016
    On Monday, 29 December 2008 23:08:30 UTC+5:30, John B. Matthews wrote:
    In article <09420b4c-2d19-4f07-ba9f-5d5a7ce1e26d@i20g2000prf.googlegroups.com>,
    Arun <setsun@gmail.com> wrote:

    On Dec 29, 8:29 pm, "John B. Matthews" <nos...@nospam.com> wrote:
    [...]
    <http://java.sun.com/docs/books/tutorial/essential/regex/>

    What syntax errors did this approach discover?

    [Please trim sigs.]

    I think I did not explain my requirement.
    I have 3 lines

    LINE 1 -> :61:0112201223CD110,92NDIVNONREF//08 IL053309
    LINE 2 -> /GB/2542049/SHS/312,
    LINE 3 -> :62F:C011021USD175879,84

    And I grab line 1 & 2 using pattern "(:61:.*?.[^:]+)" and copy it to
    a StringBuffer. Now, with matcher.group(int arg) function, i need to
    group the sequence so that i can get the 2nd line.

    matcher1.group(1) should return :61:0112201223CD110,92NDIVNONREF//08 IL053309 ( along with the \n ) and matcher1.group(2) should return /GB/ 2542049/SHS/312,
    [...]

    You could try matching the \n:

    Pattern p = Pattern.compile("(^.*\n)(.*\n)", Pattern.DOTALL);
    Matcher m = p.matcher(s);
    if (m.matches()) ...

    Again, an <http://sscce.org/> would make discussion easier.

    [Please trim sigs.]

    --
    John B. Matthews
    trashgod at gmail dot com
    http://home.roadrunner.com/~jbmatthews/

    Hi John, i came across one of your post today regarding parsing MT940 file. I am working on a requirement were the file looks as below;
    :61:161107D6243,23NXPC2000136822
    :86:XPC?00ISSUANCE?20INV:5111107901 DTE:20161107 AMT:742.00?21INV
    :5111107903 DTE:20161107 AMT:994.74?22INV:5111107869 DTE:201611
    07 AMT:479.00?23INV:5111107872 DTE:20161107 AMT:850.00?24INV:511
    1107873 DTE:20161107 AMT:500.44?25INV:5111107875 DTE:20161107 AMT :634.30?26INV:5111107897 DTE:20161107 AMT:405.10?27INV:51111079
    00 DTE:20161107 AMT:1020.25?27INV:5111107867 DTE:20161107 AMT:61 7.40?30CITISUPLFIN?31109087?32LOOS AND CO INC?3324356
    I want only the keytags to start with a colon and not other lines. The expected output is i want them in a straight line instead of multiple lines. Please help me.

    - Muru

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)