regexpentaho

How to add zero in front of single digit values using REGEX in pentaho


I have the month values in a flat file like

Month
  12
  11
   1
   2
   8
  10

now i want to add zero in front of single digit values & double digit as same.

output should be like

Month
  12
  11
  01
  02
  08
  10

This am doing in PENTAHO (I will implement in Replace in string step)


Solution

  • I am not aware of PENTAHO. But following regex should work for most of the languages

    Match : \b([1-9])\b

    Replace : 0$1

    regex101 demo