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线程的创建、挂起、激活与终止

Delphi编程获取系统当前进程、窗口句柄、文件属性

Delphi winsock远程唤醒计算机的函数

Delphi 获取指定进程中的~内存数据

Delphi获取其他进程中listbox和combobox的内容

Delphi psafearray与tbytes类型转换

Delphi研究之驱动开发篇(六)--利用section与用户模式程序通讯(上)

Delphi ado 连接 excel (附excel各个版本的版本号)

Delphi外挂编写

Delphi richedit 的scrollbar自动向下滚动

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



打赏

取消

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

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

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

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

评论

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