Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Adding character to string variable depending on the length of characters in the same string

    Hi,

    I've got a string variable, which should have 10 characters.
    I need to add a "0" in the front of the string but only if the string is 9 characters long.

    ex.
    Var 1
    0123456789
    123456789
    0123456789

    I'm using replace var1= "0" + var1 but missing the part where I can depend the command to only occure if the string is 9 characters.

    Any help is very much appreciated

    Best
    Charlotte

  • #2
    You'll probably want to use strlen()
    Code:
    replace var1 = "0" + var1 if strlen(var1)==9

    Comment


    • #3
      Thanks
      It works perfectly

      Comment

      Working...
      X