oracle - 如何删除或跳过字符串中的多个新行?
问题描述
DECLARE
v_string VARCHAR2(4000) := 'A database is an organized collection of data,
generally stored and accessed electronically
from a computer system. Where databases are more
complex they are often developed
using formal design and modeling techniques.';
v_sql_code_new VARCHAR2(4000);
BEGIN
END;
/
Desired output:
A database is an organized collection of data,
generally stored and accessed electronically
from a computer system. Where databases are more
complex they are often developed
using formal design and modeling techniques.
我正在尝试从字符串中删除所有换行符。我尝试使用 regexp_replace 但无法获得所需的结果。谢谢先进
解决方案
虽然您也可以使用'^\s*$'
with modifier=>'mn'
,但最简单的方法是替换多个 chr(10):
DECLARE
v_string VARCHAR2(4000) := 'A database is an organized collection of data,
generally stored and accessed electronically
from a computer system. Where databases are more
complex they are often developed
using formal design and modeling techniques.';
v_sql_code_new VARCHAR2(4000);
BEGIN
dbms_output.put_line(regexp_replace(v_string,chr(10)||'(\s*'||chr(10)||')+',chr(10)));
END;
/
\s*
这里只是删除只包含空格字符的行。
推荐阅读
- python - 用于 16 位灰度图像的 cvtColor “代码”
- aws-powershell - 使用 PowerShell 的 AWS VPNConnection
- amazon-web-services - Jenkins ecs 命令未找到
- github - 如何使用 Jekyll 站点设置 RSS 提要?
- kubernetes - 如何在 GKE 上设置 GRPC Ingress(使用 nginx-ingress)
- c# - 将条件语句放在 C# 中的静态类中
- javascript - 使用带有加载器和 AfterViewInit 的 ng2-charts
- audiounit - AUv3 AudioUnit 扩展,IPCAUClient:捆绑显示名称为 nil
- python - 遍历文件但跳过子目录
- r - Rmakrdown 不使用最新版本的包函数来生成 github markdown (md) 文件?