Announcement

Collapse

Mirth Connect 4.1.1 Released!

Mirth Connect 4.1.1 is now available as an appliance update and on our GitHub page. This release contains modifications to the Welcome to Mirth Connect screen and two fixed defects. See the release notes for the list of fixes and updates.

Download | See What's New | Upgrade Guide | Release Notes

For discussion on this release, see this thread.
See more
See less

Regular Expressions

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Regular Expressions

    Hi

    I'm having trouble using the String Replacement option in the transformer.
    How can I split a 14 digits number into 3 parts?

    Ex:

    21457521064124

    214 (3 digits)
    5752106 (7 digits)
    4124 (4 digits)


    I've tried the regular expression option in the transformer (Mapper) and Javascript code like this:

    var number = msg['ORC']['ORC.2']['ORC.2.1'].toString();
    var ar = number.match(/(ddd)(ddddddd)(dddd)/);
    connectorMap.put('a', RegExp.$1);
    connectorMap.put('b', RegExp.$2);
    connectorMap.put('c', RegExp.$3);


    Can you help me?

  • #2
    Re:Regular Expressions

    You will have 3 different variables defined as Javascript.

    Ex:
    21457521064124

    Map variable A:
    var a = ([msg['ORC']['ORC.2']['ORC.2.1'].substring(0,2); // e.g. a = "214"
    return a;

    ....and so on.

    Comment

    Working...
    X