[Object DataSources] Regular Expression In Object DataSource

This recipe shows how to use regular expressions in an object datasource.

Steps taken:

  1. Create an object datasource (RegEx.ds).
  2. Enter the following script into the “DataSource Wizard > JavaScript” tab page:function pushTo(/PushContext/ cxt, /DataListener/ dl)
    {

dl.startData(this);
var input = “${Data##Ref,Ref,Ref,Ref,Ref,Ref,Ref,Ref,Ref,Ref,Ref,Ref,Ref,Ref,Derivative,Discard,Derivative,Derivative,
ParameterSupplier,ParameterSupplier,Derivative,Derivative,Derivative,ParameterSupplier,ParameterSupplier,Derivative,
Derivative,Derivative,ParameterSupplier,ParameterSupplier,Derivative,Derivative,Derivative,Concat,Derivative,Derivative,
ParameterSupplier,Processor,Group,Cube,Derivative,Discard,Derivative,Derivative,Derivative,Filter,Processor,Derivative,
Discard,Derivative,Derivative,ParameterSupplier,ParameterSupplier,Derivative,Derivative,Derivative,ParameterSupplier,
ParameterSupplier,Derivative,Derivative,Derivative,Concat,Derivative,Derivative,ParameterSupplier,Processor,Group,Cube,
Derivative,Discard,Derivative,Derivative,Derivative,Filter,Processor,Concat}”//var input = “a) Apple b) Boy c) cat d) dog e) elephant”;
var ss = input.split("${delimiter}");

for (var i=0;i {

var rec = this.newRecordInstance();
var data = rec.getData();// process record using ss[i]
data[0] = ss[i];
dl.processRecord(rec);
}

dl.endData(this);

}
3. When it’s loading data, enter “a”, “b”, or “c” into the delimiter. You will see the different outputs.

To download the necessary files for this recipe, refer to the attached ZIP package.
RegExInObj.zip