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

效果

相关推荐
zxrhhm1 小时前
MySQL 索引回表(Back to Table)详解
数据库·mysql
m0_741481781 小时前
Vue.js核心基础之响应式系统与虚拟DOM渲染关联机制
jvm·数据库·python
Gauss松鼠会1 小时前
GaussDB数据库统计信息自动收集机制
数据库·经验分享·sql·oracle·gaussdb
许彰午1 小时前
# Oracle shutdown immediate关不掉——一次排坑实录
数据库·oracle
消失的旧时光-19431 小时前
SQL 怎么学(工程实战总纲|用一套用户模型打穿全流程)
java·数据库·sql
abc123456sdggfd2 小时前
如何统一SQL视图报错信息_使用异常处理机制包装视图
jvm·数据库·python
qq_460978402 小时前
如何处理SQL循环逻辑_探索递归CTE实现复杂计算
jvm·数据库·python
码农阿豪2 小时前
Django接金仓数据库:我踩过的坑和填坑指南
数据库·python·django
疯狂成瘾者2 小时前
Prompt分层策略
前端·数据库·prompt