Oracle SQL Regexp_replace匹配 [英] Oracle SQL Regexp_replace matching

查看:410
本文介绍了Oracle SQL Regexp_replace匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我需要完成的时髦匹配.

Here is a funky matching that I need to accomplish.

A5.1.9.11.2

需要成为:

A05.01.09.11.02

DOT部分的数量从无到多.并且字母"A"将始终存在且始终为1个字符.

The amount of DOT sections will vary from none to many. And the letter "A" will always be there and always be 1 character.

我想使用regexp_replace()函数以便将其用作排序机制.谢谢.

I would like to use the regexp_replace() function in order to use this as a sorting mechanism. Thanks.

推荐答案

Oracle SQL不支持环视断言,在这种情况下这将很有用:

Oracle SQL doesn't support lookaround assertions, which would be useful for this case:

s/([0-9](?<![0-9]))/0\1/g

您必须至少使用两个替换项:

You'll have to use at least two replacements:

REGEXP_REPLACE(REGEXP_REPLACE(col, '([0-9]+)', '0\1'), '0([0-9]{2})', '\1')

这篇关于Oracle SQL Regexp_replace匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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