SAP 剑客
于 2017-01-17 15:28:03 发布
6181
收藏 4
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本节我们学习函数:Text.Remove
Removes all occurrences of a character or list of characters from a text value. The removeChars parameter can be a character value or a list of character values.
用法: Text.Remove(text as nullable text, removeChars as any) as nullable text
Argument | Description |
---|---|
text | The text to parse. |
removeChars | A character value or a list of character values to be removed. |
Example1: Text.Remove(“a,b,;c”,”,”)equals “ab;c”
Example2: Text.Remove(“a,b,;c”,{“,”,”;”}) equals “abc”
从上面的用法可以看出,Text.Remove()由两个参数组成,第一个是源字符串,后面一个可以是一个字符也可以是一个集合,用于去除前面字符串中的某些字符。
例如:Text.Remove(“111122223333abcdefg”,”1”) 从字符串中去掉字符 “1”。
又例如:Text.Remove(“11112233abcdefg4445554hg66fd6”,{“1”..”9”}) 从字符串中去掉字符 “1”~“9”。
再例如:Text.Remove(“11A1 我 12 是 C233a 中 bBcde 国 fg44H4 人 5554hg66fd6”,{“1”..”9”,”a”..”z”,”A”..”Z”}) 从字符串中提取汉子。
附加:汉字范围:“一”..“龥” (按住 Alt+64923)。
下面我们看一个小例子:
根据上图中的中英文名字,分别显示每个人的中文名和英文名。
用上面的 Text.Remove 函数简直易如反掌。
首先得到中文名:Text.Remove([中英文名],{“a”..”z”,”A”..”Z”})
其次得到英文名:Text.Remove([中英文名],{“一”..”龥”})
最后对两列进行修整即可。
最后每一次的更新都可以及时刷新。