Question

Split an attribute into two groups: Numbers and letters

  • 15 October 2013
  • 5 replies
  • 17 views

Badge
Hi

 

 

I have an attribute consisting of 1-4 numbers and one letter. I would like to split it into two.

 

 

Examples: 1A, 10B, 100C etc.

 

 

I have tried AttributeSplitter, but no luck yet. Hope someone can help me.

 

 

Regards,

 

Stig

5 replies

Userlevel 2
Badge +17
Hi Stig,

 

 

The StringSearcher transformer can do that with this regular expression, for example: ^([0-9]{1,4})([A-Z])$

 

 This expression is more lenient: ^([0-9]+)([A-Z]+)$

 

 

Takashi
Badge
Thanks very much, Takashi. It works!
Userlevel 4
Hi,

 

 

just be aware that the regexp will not work if your attribute contains accents or international characters outside of the english alphabet.

 

 

David
Userlevel 4
By the way, here is my suggested modification so that it also supports accents, etc:

 

 

^([0-9]+)(.+)$

 

 

David
Badge
Thanks, David. I might have special characters in the future, so it is very helpful.

Reply