Skip to main content

i have HSN field and some times those are having special characters, if it is not having any special character and it having single special character no need to select.

 

But here which string having more than one special character then select.

Special characters: /-

HSN1-11-11-11/22/21-2/21/2-2/2

 

In above table i need to select on yellow highlighted data only \\

Are all non special characters numbers?


Hi @tomjerry.vl,

Please use a StringSearcher with the expression '[/-]' and Advanced - All Matches List Name set to '_matches'. THis will create a list of all the special character matches in the string.

Next, we want to find the features with more than one element in the list, which we can do with a ListElementCounter on the _matches{} list. Use a Tester afterwards to find _element_count > 1.


I would use the StringLengthCalculator to calculate the original length of the string.

Then use a StringReplacer to remove all special characters.

Repeat the StringLengthCalculator and use an AttributeCretator to calculate the difference in length.

That will tell you the number of special characters.

Could also be done in one AttributeCreator using string functions like StringLength and ReplaceString in the Text Editor.


I would use the StringLengthCalculator to calculate the original length of the string.

Then use a StringReplacer to remove all special characters.

Repeat the StringLengthCalculator and use an AttributeCretator to calculate the difference in length.

That will tell you the number of special characters.

Could also be done in one AttributeCreator using string functions like StringLength and ReplaceString in the Text Editor.

ok but too lengthy process


ok but too lengthy process

To use just the one transformer (AttributeCreator) you can use this logic:

It will calculate the number of - and / characters in the test string.


I would use the StringLengthCalculator to calculate the original length of the string.

Then use a StringReplacer to remove all special characters.

Repeat the StringLengthCalculator and use an AttributeCretator to calculate the difference in length.

That will tell you the number of special characters.

Could also be done in one AttributeCreator using string functions like StringLength and ReplaceString in the Text Editor.

yes it working


Here is an alternative that uses only one transformer with a regular expression:

Using a StringSearcher, paste the following Regular Expression to match your cases:

[-\\/].*[-\\/]

 

This will output your required features in the Matched port.


Hi @tomjerry.vl,

Please use a StringSearcher with the expression '[/-]' and Advanced - All Matches List Name set to '_matches'. THis will create a list of all the special character matches in the string.

Next, we want to find the features with more than one element in the list, which we can do with a ListElementCounter on the _matches{} list. Use a Tester afterwards to find _element_count > 1.

ok but in fme 2017.1 version ListElementCounter parameters no list attribute available how to resolve this issue please tell me

 


ok but in fme 2017.1 version ListElementCounter parameters no list attribute available how to resolve this issue please tell me

 

Clicking on the triangle beside Advanced in the transformer settings should expose the list entries for you.


Here is an alternative that uses only one transformer with a regular expression:

Using a StringSearcher, paste the following Regular Expression to match your cases:

[-\\/].*[-\\/]

 

This will output your required features in the Matched port.

I have used this expression " @StringLength(@Value(housenumbe))-@StringLength(@ReplaceRegEx(@Value(housenumbe),,-/],,true)) "

then output result is shown below

5-4

3-2

6-4

5-3

9-6

I want total subtraction value

like this

1

1

2

2

3

please tell me sir


I have used this expression " @StringLength(@Value(housenumbe))-@StringLength(@ReplaceRegEx(@Value(housenumbe),[-/],,true)) "

then output result is shown below

5-4

3-2

6-4

5-3

9-6

I want total subtraction value

like this

1

1

2

2

3

please tell me sir

To do the math, you will need the @Evaluate() function.


If an attribute contains the value 5-4 and you need it to be 1, you can use the ExpressionEvaluator transformer to do the math.

Hope this helps.


Reply