in reply to How to convert a string with regex to a string with a fixed length?

Simplifying a little the idea from moritz you could try this:

/^(.{1,7})$/${1}000000/ /^(.{1,10})$/${1}000/ /^(.{1,11})$/${1}00/ /^(.{1,12})$/${1}0/

Note that the single space between each pair of regex is important, as stated in the doc you posted.

Rule One: "Do not act incautiously when confronting a little bald wrinkly smiling man."

  • Comment on Re: How to convert a string with regex to a string with a fixed length?
  • Download Code