Skip to main content

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?

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


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