delphi 过滤字符串首位特殊符号


本文整理自网络,侵删。

 
// 用法:ShowMessage (TrimEx('<MegaTeg>', '<>'));

function TrimEX(Word, TrimSymbols: string): string;

var

x, a, b: Integer;

begin

Result := Word;

if TrimSymbols = '' then

   exit;

Word := Trim(word);

if length(word) = 0 then

   exit;

 

x := 0;

repeat

   x := x + 1;

until (pos(ansiuppercase(word[x]), ansiuppercase(TrimSymbols)) = 0)

   or (x = length(word));

a := x;

 

x := length(word) + 1;

repeat

   x := x - 1;

until (pos(ansiuppercase(word[x]), ansiuppercase(TrimSymbols)) = 0)

   or (x = 1);

b := x;

 

word := copy(word, a, b - a + 1);

result := word;

end;

相关阅读 >>

Delphi msxml 获取 api接口

Delphi f1026 file not found: ''quickrpt.dcu''解决方法

Delphi静态和动态调用dll的实例

Delphi 我的电脑连接到 internet 了吗?

Delphi反调试【初级】检测法

Delphi 去字符串长度函数 strlen,length

Delphi 判断某个系统服务是否存在及相关状态

Delphi mscomm1自动获取串口

Delphi得到字符串中第一个汉字的位置

Delphi中启用禁止cd驱动器自动运行播放

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...