Regexp in SMAT: messages with certain amount of FT1-segments

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Regexp in SMAT: messages with certain amount of FT1-segments

  • Creator
    Topic
  • #55691
    Robert Kersemakers
    Participant

      Hi all,

      I’m really crap at regexp. I have the need to search a SMAT (file) with a regexp for DFT messages that have 18, 19 or 20 FT1 segments. (Don’t ask why, it’s a long story).

      So I started with

      Code:

      (rFT1.*?){18}

      which kinda works, but gives me all messages that have at least 18 FT1 messages.

      Searched the internet for help and tried some things, but none work:

      Code:

      (rFT1.*?){18,20}?$
      (rFT1.*?){18,20}(?=r)
      (rFT1.*?){18}((rFT1.*?){2})?
      (?<=[^(rFT1.*?)]|^)((rFT1.*?){18})(?:[^(rFT1.*?)]|$)

      Is there a regexp that will add all messages with 18, 19 or 20 FT1 segments? Or for exactly 18 FT1 segments?

      While typing this question, I figured out that I can first add the messages with at least 18 FT1 segments and then remove all messages with at least 21 FT1 segments. Duh… But maybe there is a regexp that can do this in one go.

      Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

    Viewing 1 reply thread
    • Author
      Replies
      • #86182
        David Barr
        Participant

          Can you use the set ID (field one in the FT1) as part of your pattern? Do you know what segments come before and after the FT1?

          If you know that there’s always a PID or PV1 before the FT1, and the FT1 will always be the last segment in the message, I think you can use this:

          Code:

          r(PID|PV1)[^r]*(rFT1[^r]*){18,20}r$

        • #86183
          Robert Kersemakers
          Participant

            Hi David,

            Alas: the set ID is not filled by the supplying system. That would have been too easy… 😉

            Your regexp works! I’m going to try to decypher it. Thanks!!

            Zuyderland Medisch Centrum; Heerlen/Sittard; The Netherlands

        Viewing 1 reply thread
        • The forum ‘Cloverleaf’ is closed to new topics and replies.