如何在pentaho中使用正则表达式在个位数值前添加零 [英] How to add zero in front of single digit values using REGEX in pentaho

查看:43
本文介绍了如何在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.

输出应该是这样的

Month
  12
  11
  01
  02
  08
  10

这是在 PENTAHO 中做的(我将在替换字符串步骤中实现)

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

推荐答案

我不知道 PENTAHO.但是遵循 regex 应该适用于大多数语言

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

匹配: \b([0-9])\b

替换: 0$1

regex101 演示

这篇关于如何在pentaho中使用正则表达式在个位数值前添加零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆