Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个有趣的场景要- (minus sign)在数字、字母和数字之间添加。
- (minus sign)
例子:
输入:123AB56;输出:123-AB-56; 输入:56XYZ777;输出:56-XYZ-777;
输入:123AB56;输出:123-AB-56;
输入:56XYZ777;输出:56-XYZ-777;
源数据没有规则模式。
对此的任何意见表示赞赏。
如果是相对较晚的 Oracle,则可以regexp_replace执行以下任务:
regexp_replace
SELECT REGEXP_REPLACE(YOURFIELD, '([[:digit:]]+)([[:alpha:]]+)([[:digit:]]+)', '\1-\2-\3') REPLACED_RESULTS FROM YOURTABLE;