Skip to main content
Question

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

  • April 20, 2018
  • 8 replies
  • 316 views

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.
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

8 replies

erik_jan
Contributor
Forum|alt.badge.img+22
  • Contributor
  • 2179 replies
  • April 20, 2018

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

(meaning start then only digits then end).


david_r
Celebrity
  • 8394 replies
  • 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+22
  • Contributor
  • 2179 replies
  • April 20, 2018

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

Test for Type Numeric.


danilo_fme
Celebrity
Forum|alt.badge.img+51
  • Celebrity
  • 2077 replies
  • 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
Celebrity
  • 8394 replies
  • April 20, 2018

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
  • 2252 replies
  • April 20, 2018

something wrong with this service?

This post is old, is it not?


david_r
Celebrity
  • 8394 replies
  • April 20, 2018

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
  • Author
  • 7 replies
  • April 23, 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.

It works! Thank you very much