我的字符串就像" Vinoth ^ Vinoth Karthick Vinoth ^ Vinoth ^ Vinoth"由" ^"分隔。我想用XXX代替Vinoth。
I/P String : Vinoth^Vinoth Karthick Vinoth^Vinoth^Vinoth
Expected output : XXX^Vinoth Karthick Vinoth^XXX^XXX
请使用Regexp_replace或ORACLE SQL语句中的任何其他函数建议如何执行此操作。
答案 0 :(得分:2)
将分隔符let data = new FormData()
data.append('name', 'hey')
fetch('http://homestead.test/api/customers', {
method: 'POST',
headers: {
'Content-type': 'multipart/form-data'
},
body: data
})
.then((response) => {
// now you can access response here
console.log(response)
})
加倍并将字符串换成分隔符^
字符,以便每个元素都有自己独特的前导和尾随分隔符,然后您只需用{{^
替换^Vinoth^
1}}并反转分隔符的加倍并修剪前导和尾随分隔符:
Oracle 11g R2架构设置:
^XXX^
查询1 :
SELECT 1 FROM DUAL;
<强> Results 强>:
SELECT TRIM(
'^' FROM
REPLACE(
REPLACE(
'^' ||
REPLACE(
'Vinoth^Vinoth Karthick Vinoth^Vinoth^Vinoth',
'^',
'^^'
)
|| '^',
'^Vinoth^',
'^XXX^'
),
'^^',
'^'
)
) AS replaced
FROM DUAL
答案 1 :(得分:0)
又一个选择:
SQL> with test (col) as
2 (select 'Vinoth^Vinoth Karthick Vinoth^Vinoth^Vinoth' from dual),
3 inter as
4 (select regexp_substr(replace(col, '^', ':'), '[^:]+', 1, level) col,
5 level lvl
6 from test
7 connect by level <= regexp_count(col, '\^') + 1
8 )
9 select listagg(regexp_replace(col, '^Vinoth$', 'XXX'), '^')
10 within group (order by lvl) result
11 from inter;
RESULT
-----------------------------------------------------------------------------
XXX^Vinoth Karthick Vinoth^XXX^XXX
SQL>