当角色的出现不断变化时,我如何在角色之后获得串联
示例
123\.456.578.910.ABC
123\.456.578.910
预期结果
123\.456.578
123\.456.578
对于这两个输入,我应该只得到前 3 个输入,
我尝试了正则表达式、子字符串和指令,但没有得到结果
Example
123\.456.578.910.ABC
123\.456.578.910
Expected result
123\.456.578
123\.456.578
For the both the inputs I should get only the first 3
I tried the regexp and substring and instr but I’m not getting the results
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您的价值将始终具有至少3
。
字符,则可以使用:如果它可能具有较少的情况,并且在这些情况下需要整个字符串:
对于您的示例数据:这两个
输出:这两个输出:
db<> fiddle 此处
If you value will always have at least 3
.
characters then you can use:If it may have fewer and you want the entire string in those cases then:
Which, for your sample data:
Both outputs:
db<>fiddle here
我们可以在此处使用一个捕获组:
We can use
REGEXP_SUBSTR
here with a capture group:Demo
传统,
substr
+instr
组合是另一个选项:示例数据:
查询从这里开始:
Traditional,
substr
+instr
combination is another option:Sample data:
Query begins here: