Skip to main content
Solved

Attribute to specific form


Forum|alt.badge.img

Hi,

Was thinking what would be simpliest way to make this..

For example making 1-2000-K35 to 0012000K000035

So idea is to have bunch of values into this same form.. (000-0000-K000000, without "-")

Not sure how to explain it easier.

For now I can make it with splitter, bunch of testers and concatenator.. Would think there is easier way to make it. Maybe with some regular expressions?

Best answer by takashi

I would split the source string using a StringSearcher with these parameters.

  • Contains Regular Expression: ^(\d+)-(\d+)-(\D)(\d+)$
  • Subexpression Matches List Name: _sub

Then, you can format each number part (_sub{0}.part, _sub{1}.part, _sub{3}.part) with StringFormatters as @redgeographics suggested, and concatenate all the elements of _sub{}.part.

Alternatively, this string expression performs formatting and concatenating at once.

@Format(%03s,@Value(_sub{0}.part))@Format(%04s,@Value(_sub{1}.part))@Value(_sub{2}.part)@Format(%06s,@Value(_sub{3}.part))

See here to learn how to use the @Format function: String Functions

View original
Did this help you find an answer to your question?

2 replies

redgeographics
Celebrity
Forum|alt.badge.img+50

I think you're on the right track. StringFormatter may come in useful too to add leading 0's


takashi
Evangelist
  • Best Answer
  • November 2, 2017

I would split the source string using a StringSearcher with these parameters.

  • Contains Regular Expression: ^(\d+)-(\d+)-(\D)(\d+)$
  • Subexpression Matches List Name: _sub

Then, you can format each number part (_sub{0}.part, _sub{1}.part, _sub{3}.part) with StringFormatters as @redgeographics suggested, and concatenate all the elements of _sub{}.part.

Alternatively, this string expression performs formatting and concatenating at once.

@Format(%03s,@Value(_sub{0}.part))@Format(%04s,@Value(_sub{1}.part))@Value(_sub{2}.part)@Format(%06s,@Value(_sub{3}.part))

See here to learn how to use the @Format function: String Functions


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