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

效果

相关推荐
笃行35014 分钟前
KingbaseES KSQL Developer 的连接管理、数据处理与对象管理
数据库
ha_lydms25 分钟前
MaxCompute中加密与解密函数
大数据·数据库·数据仓库·hadoop·dataworks·maxcompute·odps
Shadow(⊙o⊙)1 小时前
MySQL内置函数
数据库·mysql
笃行3501 小时前
金仓 KingbaseES PL/SQL 开发全攻略:异常处理、数据类型、调试优化与过程语句
数据库
快乐的木子李2 小时前
mysql-26.7.0-linux26.7.0下载安装
数据库·mysql
excel3 小时前
prisma 如何处理数据库竞态
前端·数据库·后端
知行产研4 小时前
易控智驾:毛利率跃升17.2个百分点,矿山无人驾驶从“规模换增长“迈入“盈利拐点“
数据库·mysql
千里码aicood4 小时前
基于CART算法的图书分类系统设计与实现
数据库·算法·分类
饺子大魔王的男人4 小时前
Redis 内存和连接异常怎么排查?用 redis_exporter 搭一套可远程抓取的监控链路
数据库·redis·bootstrap
可涵不会debug4 小时前
第一次学 LangGraph:用一个快递案例搞懂 State、Node、Edge 和 compile
服务器·数据库·mysql