Skip to main content
Question

How Do I select a string that only consits of a number.


Forum|alt.badge.img

Hello,

 

 

I would like to replace the strings that only consists of number for example :11

Although I have string that are for example 11 xxx which should not be replaced.

 

 

In short, if the digit is followed by any word character Stringreplacer shouldn't select it but if the number is there buy itself then select it.

8 replies

erik_jan
Contributor
Forum|alt.badge.img+17
  • Contributor
  • April 20, 2018

You could use the StringSearcher transformer with the regular expression: ^[0-9]*$

(meaning start then only digits then end).


david_r
Evangelist
  • April 20, 2018

Try the following in a StringReplacer:

^\d+$

It will only replace the attribute values that are entirely made up of one or several digits.


erik_jan
Contributor
Forum|alt.badge.img+17
  • Contributor
  • April 20, 2018

Or you could use the AttributeValidator transformer to test if the attribute is numeric.

Test for Type Numeric.


danilo_fme
Evangelist
Forum|alt.badge.img+41
  • Evangelist
  • April 20, 2018

Hi @oliwerurban,

I created a Workspace to test it. The transformer AttributeCreator was used to simulate 3 attributes: Solutial, Solutial11, 11.

After the transformer StringReplacer:

Thanks,

Danilo


david_r
Evangelist
  • April 20, 2018
erik_jan wrote:

You could use the StringSearcher transformer with the regular expression: ^[0-9]*$

(meaning start then only digits then end).

Maybe consider using + rather than * to avoid matching empty values

gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • April 20, 2018

something wrong with this service?

This post is old, is it not?


david_r
Evangelist
  • April 20, 2018
gio wrote:

something wrong with this service?

This post is old, is it not?

It doesn't look very old to me, at least:

 

 


Forum|alt.badge.img
david_r wrote:

Try the following in a StringReplacer:

^\d+$

It will only replace the attribute values that are entirely made up of one or several digits.

It works! Thank you very much

 

 

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings