1 Reply Latest reply on Mar 26, 2014 11:19 AM by marcj

    Utilization of Regular Expression in Java Script Task

    marcj

      Hey guys,

      I wondered if it is possible to use regular expressions in a Java Script Task. The use case I´m trying to implement needs to validate whether a BIC (Bank Identifier Code) is valid or not and return a boolean result.

      The regular expression looks like this:

       

      var regSWIFT = /([a-zA-Z]){4}([a-zA-Z]){2}([0-9a-zA-Z]){2}([0-9a-zA-Z]{3})?$/;

       

      Is this possible within a script task?

       

      Thx in advance,

        • 1. Re: Utilization of Regular Expression in Java Script Task
          marcj

          OK, after trying several hours and a desparate posting in this forum, it just took me 30 minutes more to solve the issue:

           

          String in_bic = (String)kcontext.getVariable("BIC");

           

          if (in_bic.matches("([a-zA-Z]){4}([a-zA-Z]){2}([0-9a-zA-Z]){2}([0-9a-zA-Z]{3})?$")) {

              kcontext.setVariable("validBIC", true);

          }

          else {

              kcontext.setVariable("validBIC", false);

          }