我试试这个
SELECT regexp_replace(v_gen,'(\b[a-zA-Z]+\b)','$$1%')INTO v_test FROM DUAL;
它应该在'hello world word'
$hello% $world% $word%'
Oracle文档不清楚函数regexp_replace
与group ...
答案 0 :(得分:1)
regexp_replace('hello world word','([a-zA-Z]+)','$\1%')
\1
为您提供与模式匹配的字符串,然后我们将其格式化,附加所需的其他字符。
[a-zA-Z]+
查找所有连续的字母序列。
([[:alnum:]]+)
将查找字母数字字符序列。如果你想要一个,你可以使用它。
示例:使用多个选项
with my_text as
(
select 'hello world word' as str from dual
)
SELECT regexp_replace(str,'([[:alnum:]]+)','$\1%') FROM my_text
union all
SELECT regexp_replace(str,'([[:alpha:]]+)','$\1%') FROM my_text
union all
SELECT regexp_replace(str,'([a-zA-Z]+)','$\1%') FROM my_text
REGEXP_REPLACE(STR,'([
----------------------
$hello% $world% $word%
$hello% $world% $word%
$hello% $world% $word%