ABAP中字符串相关比较
The following table shows the relational operators for comparisons between character-like operands (single data objects or return values or string expressions) in comparison expressions.
The trailing blanks are respected for operands of type string. If not stated differently in the following table, the trailing blanks are ignored for operands of types c, d, n, and t.
| operator | Meaning |
| CO | Contains Only: True, if operand1 only contains characters from operand2. It is case-sensitive and trailing blanks are respected in both operands. If operand2 is of type string and initial, then the relational expression is false, except if operand1 is also of type string and initial. If operand1 has the type string and is initial, the relational expression is always true, regardless of operand2. If the comparison is true, sy-fdpos contains the offset of the first character in operand1 that is not contained in operand2. If the comparison is true, sy-fdpos contains the length of operand1. |
| CN | Contains Not Only: True if a relational expression with CO is false, that is, if operand1 contains not only characters from operand2. sy-fdpos is set in the same way as for CO. If the comparison is true, sy-fdpos contains the offset of the first character in operand1 that is not contained in operand2. If the comparison is false, sy-fdpos contains the length of operand1. |
| CA | Contains Any: True, if operand1 contains at least one character from operand2. It is case-sensitive and trailing blanks are respected in both operands. If operand1 or operand2 are of the type string and initial, the relational expression is always false. If result of the comparison is positive, sy-fdpos contains the offset of the first character in operand1 that is also contained in operand2. If the comparison is false, sy-fdpos contains the length of operand1. |
| NA | Contains Not Any: True, if a relational expression with CA is false, that is if operand1 does not contain any characters from operand2. If the comparison is false, sy-fdpos contains the offset of the first character in operand1 that is also contained in operand2. If the comparison is true, sy-fdpos contains the length of operand1. |
| CS | Contains String: True, if the content of operand2 is contained in operand1. It is not case-sensitive and trailing blanks in the left operand are respected. If operand1 is of type string and initial, or of type c and contains only blank characters, the relational expression is false, unless operand2 is also of type string and initial, or of type c and only contains blank characters. In this case, the relational expression is always true. If the comparison is true, sy-fdpos contains the offset of operand2 in operand1. If the comparison is false, sy-fdpos contains the length of operand1. |
| NS | Contains No String: True, if a relational expression with CS is false, that is if operand1 does not contain the content of operand2. If the comparison is false, sy-fdpos contains the offset of operand2 in operand1. If the comparison is true, sy-fdpos contains the length of operand1. |
| CP | Covers Pattern: True, if the content of operand1 fits the pattern in operand2. Wildcard characters can be used to create the operand2 pattern, where "*" represents any character string (including a blank string) and "+" represents any character. It is not case-sensitive. Trailing blanks in the left operand are respected. If the comparison is true, sy-fdpos contains the offset of operand2 in operand1, whereby leading wildcard characters "*" in operand2 are ignored if operand2 also contains other characters. If the comparison is false, sy-fdpos contains the length of operand1. Characters in operand2 can be selected for direct comparisons by prefixing them with the escape character"#". For characters flagged in this way in operand2, the operator is case-sensitive. Also, wildcard characters and the escape character are not subject to special handling and trailing blanks are relevant. |
| NP | No Pattern: True, if a relational expression with CP is false, that is, if operand1 does not fit the pattern operand2. If the comparison is false, sy-fdpos contains the offset of operand2 in operand1, whereby leading wildcard characters "*" in operand2 are ignored if operand2 also contains other characters. If the comparison is true, sy-fdpos contains the length of operand1. |
Notes
- The operators CP and NP
use multiple wildcard characters "*" in a row in the
same way as a single "*" character. The wildcard
character "+" does not represent a blank string.
- Operands of byte-like data types can only be compared with the relational
operators in this table outside of Unicode programs. To execute the
corresponding comparisons for byte-like operands in Unicode programs, the relational operators for byte-like
data types can be used.
- The relational operators in this table can be replaced by predicate functions.
- The statement FIND and the search functions find can be
quicker than the relational operator CS by some
magnitude.
Example
Searches for HTML tags in a text using operator CP.
This search finds the first HTML tag "<i>" at offset 8. Note that it is
not enough to specify a search pattern "<*>",
since CP stands for Covers Pattern, and not for
Contains Pattern. The example also shows that leading wildcard characters "*" in the string are ignored in sy-fdpos so that the occurrence found by this search can be
identified.
DATA html TYPE string.
html = `This
is <i>italic</i>!`.
IF html CP '*<*>*'.
cl_demo_output=>display_text( |Found HTML tag at { sy-fdpos }| ).
ENDIF.
以上字符串的比较,都是有返回sy-fdpos
CS在很多的时候可以看成SEARCH/FIND使用,但是对特殊字符,CS要优先于其他。
ABAP中字符串相关比较的更多相关文章
- 理解CSV文件以及ABAP中的相关操作
在很多ABAP开发中,我们使用CSV文件,有时候,关于CSV文件本身的一些问题使人迷惑.它仅仅是一种被逗号分割的文本文档吗? 让我们先来看看接下来可能要处理的几个相关组件的词汇的语义. Separat ...
- js中字符串相关知识点总结
有引号就是字符串类型 空格也算长度 字符串的length不可写 typeof 判断数据类型 var s="a bcadde你好" // alert(typeof s) ...
- PostgreSQL中字符串相关问题
PostgreSQL的字符串类型有character.character varying和text的值.在使用character类型的时候, 它有自动填充空白的潜在影响,特别是在其它数据库(MySQL ...
- Java中字符串相关操作(判断,增删,转换)
1:判断字符串中是否包含某个字符(字符串): startsWith(): 这个方法有两个变体并测试如果一个字符串开头的指定索引指定的前缀或在默认情况下从字符串开始位置 此方法定义的语法如下: publ ...
- 字符串处理:ABAP中的正则表达式
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...
- Redis字符串(STRING)中BIT相关命令
上篇文章我们对STRING数据类型中一些基本的命令进行了介绍,但是没有涉及到BIT相关的命令,本文我们就来看看几个和BIT相关的命令. 本文是Redis系列的第四篇文章,了解前面的文章有助于更好的理解 ...
- C/C++中的字符串相关姿势
这是我在<程序设计实习>课程上作的pre,目标是对C/C++中字符串的相关内容作一个尽量完整的介绍.(对于OIer可能不太实用) 课件链接: https://files.cnblogs.c ...
- SAP ABAP 处理字符串串串串串串串串(详细)
关于ABAP中处理字符串的方法,非常详细,学习过程中总结一下分享给大家,,, ABAP/4 提供多个处理类型 C 即字符串 的数据对象的关键字. 处理字符串 的方法有: 1.拆分字符串split 2. ...
- 常用linux 命令 -字符串相关
参考网络文章,个人工作总结 题记:一般对字符串的操作有以下几种:求长度,截取字符串,拼接字符串,找字符串中某个字符的索引 1 expr 命令 1.1 定义 man 手册 Print the value ...
- 【Todo】字符串相关的各种算法,以及用到的各种数据结构,包括前缀树后缀树等各种树
另开一文分析字符串相关的各种算法,以及用到的各种数据结构,包括前缀树后缀树等各种树. 先来一个汇总, 算法: 本文中提到的字符串匹配算法有:KMP, BM, Horspool, Sunday, BF, ...
随机推荐
- 一款torrent文件格式分析工具(绿色纯天然)
点击下载 1.主界面 2.文件分析(显示文件所在分片的位置) 3.获取指定分片所在的peers服务器列表 一只会铲史的猫
- 编写你的第一个 Django 应用程序,第1部分
让我们通过示例来学习. 在本教程中,我们将引导您完成基本投票应用程序 它将由两部分组成: 一个公共网站,允许人们查看投票并在其中投票. 允许您添加.更改和删除投票的管理网站. 一.开发环境搭建 第一步 ...
- Windows 提权-服务_未引用的服务路径
本文通过 Google 翻译 Unquoted Service Paths – Windows Privilege Escalation 这篇文章所产生,本人仅是对机器翻译中部分表达别扭的字词进行了校 ...
- jupyter -- 数据分析可视化开发工具
博客地址:https://www.cnblogs.com/zylyehuo/ jupyter介绍 jupyter就是anaconda提供的一个基于浏览器的可视化开发工具 jupyter的基本使用 启动 ...
- SpringBoot+Thymeleaf渲染下拉框异常解决
常规方式 <select class="form-control" name="operationType" th:field="${itemT ...
- [每日算法] leetcode第1题:两数之和
leetcode第1题入口 知识点 寻找循环体中目标值之间的关系来减少循环层数 (利用关系建立查找对方的数据结构来空间换时间) 题目描述 给定一个整数数组 nums 和一个整数目标值 target,请 ...
- MySQL函数-根据子节点查询所有父节点名称
背景 公司的一个业务系统中有区域表,整个区域是一个树结构,为了方便根据某一父节点查询所有叶子节点,提供了一个额外的字段path,按照分隔符存储了从根节点到当前节点的总路径. 表结构如下: create ...
- RegisterClass注册后getclass总是nil,why?
这个问题有点老.但是有点烦人. 一般流程是 RegisterClass后通过getclass or findclass就会成功. 可是莫名其妙出现总是返回nil.咱也不清楚,网上找了好久,一个久远的帖 ...
- 白话kotlin协程
文章同步发布于公众号:移动开发那些事白话kotlin协程 1 什么是协程 Kotlin协程(Coroutine)是一种轻量级的线程管理框架,允许开发者以更简洁,更高效的方式处理异步操作,避免回调地狱和 ...
- Unity/Auto Layout -- 理解Layout Elements(布局元素)