One Star

How to check the first three position in a input data are alpha or numeric

I need to check some condition to satisfy before inserting a data into target.
- First three position in a input should be alpha or numeric & if it is alpha should be uppercase.
-the first letter can be alpha or a special character '.'
  • Data Integration
3 REPLIES
Moderator

Re: How to check the first three position in a input data are alpha or numeric

Hi,

Could you please elaborate your case with an example with input and expected output values?

Best regards

Sabrina

Nine Stars TRF
Nine Stars

Re: How to check the first three position in a input data are alpha or numeric

 

TRF
Nine Stars TRF
Nine Stars

Re: How to check the first three position in a input data are alpha or numeric

Hi, 

You need a regex in such a case.

Suppose you have the following data flow (here in a tFixedFlowInput):

tFixedInput.png

Connect the tFixedFlowInput with a tMap and configure it as:tMap.PNG

 

 

 

 

 

The tMap contains 2 output flows called "accepted" and "rejected" (see "Catch out rejected" option for the 2nd flow).

A filter is set for the "accepted" flow using the following regex:

row1.value.matches("^\\..*") || row1.value.matches("^[0-9|A-Z]{3}.*")

This filter accept 2 kind of rows:

- rows starting with a "." followed by any sequence of characters

- rows starting by a sequence of 3 characters composed by digits (0-9) or uppercase letters (A-Z) followed by any sequence of characters

 

And the result is:

result.png

Hope this is what you expect.

 


TRF
Tags (2)