Announcement

Collapse
No announcement yet.

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