<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-M74D8PB" height="0" width="0" style="display:none;visibility:hidden">
Loading
Skip to NavigationSkip to Main Content
0D54z00009vH5rBCASOkta Classic EngineAdministrationAnswered2026-03-16T09:00:23.000Z2023-12-22T19:58:29.000Z2023-12-27T20:47:10.000Z

7jv04 (7jv04) asked a question.

How to remove ALL leading zeros in a string

Early Merry Christmas to all! (Merry Festivus for the rest of us)

The answer to this should be helpful to many: How do you create the right expression syntax to remove any/all leading zeros in a string?

Context: HR system injects leading zeros on employee number. Depending on how long the employee has existed the employee number will have more or less leading zeros. I need the expression to look for and remove any leading zeros. I've seen this in other languages including Spring/SpEL expressions, but Okta doesn't like the syntax examples I've found thus far. For example: user.MangerId("^0+", "") looks close, but no cigar.


7jv04 likes this.
  • User16594883467582706479 (Customer Support Online Experience)

    Hi, @7jv04 (7jv04)​ 

     

    Thank you for posting on our Community page!

     

    We tested it and found out you can use this expression:

    EmployeeScreenshotEarn Today: New Okta Community Badges Have Arrived

     

    Community members help others by clicking Like or Select as Best on responses. Try it today.

    _____________________________________________________________________________

     

    Expand Post
    Selected as Best
  • User16594883467582706479 (Customer Support Online Experience)

    Hi, @7jv04 (7jv04)​ 

     

    Thank you for posting on our Community page!

     

    We tested it and found out you can use this expression:

    EmployeeScreenshotEarn Today: New Okta Community Badges Have Arrived

     

    Community members help others by clicking Like or Select as Best on responses. Try it today.

    _____________________________________________________________________________

     

    Expand Post
    Selected as Best
  • 7jv04 (7jv04)

    Following up to say thanks, so thank you! I'll add that there is a twist I did not mention. The string we are stripping zeros from is alfa/numeric. I don't think Conver.toInt will work for this case, but it sure will for others. ("^0+", "") is supposedly valid syntax in the Spring Expression language, but apparently not in Okta's subset 😞

    • User16594883467582706479 (Customer Support Online Experience)

      Hi, @7jv04 (7jv04)​ 

       

      Thanks for following up. You're right, it is not covered. You could raise this as a feature request on our ideas.okta.com and maybe others in your situation could benefit from it in the future.

       

      Happy Holidays!

      Expand Post
This question is closed.
Loading
How to remove ALL leading zeros in a string