Oracle SQL 中的 Lookahead 正则表达式 - 去掉下划线后的零

发布于 2024-12-14 17:56:34 字数 427 浏览 6 评论 0原文

我使用以下正则表达式去除下划线后面的所有零: (?<=_)0+ (在 Java 中)或 /(?<=_)0+/(在 PHP 中)。

例如 Serial_Number_000000222 -> Serial_Number_222

“lookaroud”语法似乎不起作用在 Oracle 中。谁能提出替代方案?

非常感谢

I've used the following regex to strip all Zeros following an underscore: (?<=_)0+ (in Java) or /(?<=_)0+/ (in php).

E.g. Serial_Number_000000222 -> Serial_Number_222

This "lookaroud" syntax doesn't appear to work in Oracle. Can anyone suggest an alternative?

Many thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

春庭雪 2024-12-21 17:56:52

试试这个:

result := REGEXP_REPLACE(subject, '_0+', '_', 1, 0, 'c');

这会用下划线本身替换下划线,后跟一个或多个零。

Try this:

result := REGEXP_REPLACE(subject, '_0+', '_', 1, 0, 'c');

This replaces the underscore, followed by one or more zeroes, with the underscore itself.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文