我请求regexp帮助解析以下字符串:
154211202251206660
输出需要格式化如下:
1-54211-20225-12066-60
字符串长度始终相同,断点( - )始终相同。 非常感谢!
PostgreSQL 9.1.9
答案 0 :(得分:0)
将以下正则表达式与capturing group
一起使用^(\d)(\d{5})(\d{5})(\d{5})(\d{2})$
正则表达式可以与regex_replace()
regexp_replace(
TheColumn, '^(\d)(\d{5})(\d{5})(\d{5})(\d{2})$', '\1-\2-\3-\3-\4'
)