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 次替换。

效果

相关推荐
这个DBA有点耶8 小时前
从症状到根因:数据库监控指标的分层方法与静态/动态阈值策略
数据库·mysql·代码规范
SelectDB9 小时前
时间旅行与快照能力速查:Doris 侧三条落地路径
大数据·数据库·数据分析
SelectDB9 小时前
云数仓成本结构拆解速查:五层计费 vs Doris / 托管形态
大数据·数据库·数据分析
SelectDB9 小时前
什么场景能承接与建议保留:Doris vs Snowflake 边界速查
大数据·数据库·数据分析
这个DBA有点耶11 小时前
DELETE没删多少数据,表却越来越大——InnoDB删除空洞与页合并失效的根因
数据库·mysql·代码规范
ly768914 小时前
PostgreSQL 备份恢复策略:pg_basebackup、WAL 归档与 PITR 在企业 Java 系统中的落地
java·数据库·postgresql·pitr·pg_basebackup·wal 归档
小羊没烦恼!15 小时前
Ajax与JSON的一些总结
android·java·前端·数据库·mysql·算法·okhttp
注塑机数据采集联网15 小时前
如何解决注塑机数据采集联网对接MES系统数据WiFi传输数据不稳问题
大数据·数据库·物联网·数据挖掘·数据分析
黄俊懿15 小时前
【架构师从入门到进阶】第六章:服务集群优化——第八节:线程数公式
java·服务器·数据库·分布式·性能优化·架构·系统架构