OPEN SQL去掉文本中间的空格

使用OPEN SQL的函数: replace_regexpr

|--------------------------------------------------------------------------------------------------------------------------------------------------------|
| REPLACE_REGEXPR( pcre = pcre, value = sql_exp1, with = sql_exp2*[* , occurrence = occ*]* [ , case_sensitive = case*]* [ , start = start*]* ) |

|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| A Perl Compatible Regular Expression (PCRE) pcre is replaced in sql_exp1 with the character string specified in sql_exp2. occ is optional and determines the number of occurrences of pcre to be replaced. By default, all occurrences are replaced. The search is case-sensitive by default, but this can be overridden using the parameter case. The parameter start specifies the offset from which to start the search. 在 sql_exp1 中搜索符合 PCRE 正则表达式 的内容,并将其替换为 sql_exp2 指定的字符串。 * occ (occurrence):可选参数。指定替换第几次出现的匹配项。默认替换全部。 * case (case_sensitive):默认区分大小写,可通过此参数修改。 * start:指定从哪个字符位置(偏移量)开始搜索。 |

复制代码
DATA lv_empty TYPE char1.

SELECT matnr,maktx,
  replace_regexpr( pcre = '\s+',value = maktx, with = @lv_empty ) AS nospace_maktx
  FROM makt
 WHERE matnr = 'RB0009000046'
   AND spras = @sy-langu
  INTO TABLE @DATA(lt_out).
正则表达式 含义 处理方式
\s 匹配单个空白字符 发现 1 个空格,执行 1 次替换。
\s+ 匹配一个或多个连续的空白字符 发现连续的 N 个空格,把它们看作一个整体,只执行 1 次替换。

效果

相关推荐
隐退山林3 分钟前
JavaEE进阶:MyBatis 操作数据库(入门)
数据库·java-ee·mybatis
晴天¥12 分钟前
达梦数据库的内存结构
服务器·数据库·达梦数据库
倔强的石头_19 分钟前
生产环境排坑实录:SQL 标量子查询的“静默杀手”与优化器的智能推演
数据库
Navicat中国1 小时前
使用 SSL/TLS 安全连接数据库
数据库·安全·ssl
heimeiyingwang1 小时前
【架构实战】MySQL主从复制与读写分离:数据库高可用架构
数据库·mysql·架构
Cosolar1 小时前
2026年全球向量数据库技术全景与架构演进深度解析报告
数据库·人工智能·架构·agent·智能体
IronMurphy1 小时前
Redis拷打第七讲(最终章)
数据库·redis·php
张~颜1 小时前
PostgreSQL复制槽
数据库·postgresql
爱晒太阳的小老鼠1 小时前
数据库连接池Connection is not available, request timed out after 120000ms
数据库