Announcement

Collapse
No announcement yet.

SUF9 formatting multi part number

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • SUF9 formatting multi part number

    Hi,

    I suspect that this is really simple, but I simply cannot find the answer.

    I have a string value such as "1.2.3.4" which I need to 'format' as "01.02.03.0004".
    Yes, the original string might also be "1.2.34.2" which should result in "01.02.34.0002".
    - I know that the original string will be a four-part value, delimited by "." characters.

    I can't find a simple 'format' command that will do this.

    So i thought about splitting the initial string into a table (split on the "." character) and then I could loop through all entries in the table, adding the relevant number of 0's at the front.

    But I can't find a 'string.split' or similar function.

    Any ideas or suggestions most welcome.

    Cheers,
    Dave

  • #2
    You can use string.format() to format the string as "%02d.%02d.%02d.%02d".

    Ulrich

    Comment

    Working...
    X