Skip to main content
Question

Separate a string into parts according to alpha or numeric characters used


tim_bkr
Participant
Forum|alt.badge.img+5

I have an identifier attribute which can take different forms.

All contain a number, like 985 or B985 or 985a

Some are preceded by a capital letter like B985

Some are followed by a smallcaps letter or the character "*" like 985b or 985*

 

I want

  • the capital letters at the beginning of the string to go into attribute PREFIX
  • the numeric to go into attribute NUMBER
  • the smallcaps letter or the * to go into attribute SUFFIX

 

I imagine using regex is the way. I have got the job partly done with a series of StringSearchers but I'd like to have advice from someone with experience.

 

Thanks in advance !

 

 

2 replies

Forum|alt.badge.img+2

@tim_bkr​  You're probably on the right path with a regular expression in StringSearcher. Something like:

([a-zA-Z]{0,1})([0-9]+)([a-zA-Z\*]{0,1})

Go to regexr.com to learn how that expression works.

The trick is on the StringSearch under Advanced use the Subexpression Matches List Name:

dialogI've attached an example workspace (FME2021.0).

       


tim_bkr
Participant
Forum|alt.badge.img+5
  • Author
  • Participant
  • May 17, 2021

Waw, brilliant !

Thanks a ton !


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