sql - 如何在 oracle 中拆分以空格分隔的字符串并将每个单词添加到 Oracle 11g 中的不同行?
问题描述
我正在尝试拆分字符串并将每个单词添加到单独的行中。
with data as (
select 100 as id, 'python java' as src from dual
)
select id, level as lvl,
regexp_substr( src || '" "' , '([[:space:]0-9/:])', 1, level, null, 1 ) as token
from data
connect by level <= regexp_count( src || '" "' , '([[:space:]0-9/:])' )
and prior id = id
and prior sys_guid() is not null
;
我期待 python 和 java 在单独的行中。
解决方案
您的正则表达式似乎有点困惑。我认为您想要更多类似的东西:
regexp_substr( src , '(.*?)([[:space:]0-9/:]|$)', 1, level, null, 1 )
推荐阅读
- svelte - 用于 v3.12 的功能在 v3.30 中不起作用
- c# - C# 可以让用户输入设置控制台颜色吗?
- python - 在python中使用树状结构
- r - 如何在 R 中拟合 Conway-Maxwell-Poisson 回归?
- php - PHP/MySQL:取消选中数据所有复选框时保存数据时出错
- python - 使用 python 3 为文件属性添加版权
- html - 如何阻止水平边界相互重叠?
- pygame - TypeError:参数 1 必须是 pygame.Surface,而不是 builtin_function_or_method,get_rec 错误
- filepond - 尝试在每个文件池项目的基础上禁用删除
- reactjs - 缩小和悬停点时 Highchart 抛出错误