分享

自己收集的几个比较实用的Delphi字符串函数(LeftStr,MidStr,RightStr,Reverse,LastPos)

 quasiceo 2015-01-07
2006-07-12 19:46 3601人阅读 评论(1) 收藏 举报

自己收集的几个比较实用的字符串函数(LeftStr,MidStr,RightStr,Reverse,LastPos)

没什么可说的,自己看啦
//从右边取
function RightStr
    (Const Str: String; Size: Word): String;
begin
  if Size > Length(Str) then Size := Length(Str) ;
  RightStr := Copy(Str, Length(Str)-Size+1, Size)
end;
//从中间取
function MidStr
    (Const Str: String; From, Size: Word): String;
begin
  MidStr := Copy(Str, From, Size)
end;
//从左边取
function LeftStr
    (Const Str: String; Size: Word): String;
begin
  LeftStr := Copy(Str, 1, Size)
end;
//翻转字符串
Function Reverse(S : String): String;
Var
   i : Integer;
Begin
   Result := '';
   For i := Length(S) DownTo 1 Do
   Begin
     Result := Result + Copy(S,i,1) ;
   End;
End;
//取最后一个字串的位置
function LastPos(const SubStr: String; const S: String): Integer;
begin
   result := Pos(Reverse(SubStr), Reverse(S)) ;

   if (result <> 0) then
     result := ((Length(S) - Length(SubStr)) + 1) - result + 1;
end; 

主题推荐
delphi fckeditor msn word function
猜你在找
奇技淫巧之Delphi和JavaScript互通
DelPhi Treeview 操作实例 onclick节点 treeview1SelectedLevel
delphi 各种时间类型之间的转换函数
执行多条SQL语句实现数据库事务不可传入Sql参数
利用win7计划任务本地执行php脚本
窗体Form的FormStyle属性设置为fsStayOnTop时属性设置不起作用问题探讨
Spring25配置proxool连接池
Cocos2d-x 中的Sleep 和USleep
Delphi调用C++导出的类
如何能读取串口硬盘序列号出厂唯一的序列号
查看评论
1楼 dodolon 2007-03-22 20:48发表 [回复]
所列函数大多数Delphi都自带了,看下面“Delphi的字符串处理例程”:
AdjustLineBreaks function

Adjusts line break characters to reflect Windows or Linux style.

AnsiCompareStr function

Compares strings based on the current locale with case sensitivity.

AnsiCompareText function

Compares strings based on the current locale without case sensitivity.

AnsiContainsStr function

Indicates whether one string is a (case-sensitive) substring of another.

AnsiContainsText function

Indicates whether one string is a (case-insensitive) substring of another.

AnsiDequotedStr function

Converts a quoted string into an unquoted string

AnsiEndsStr function

Indicates whether one string is a (case-sensitive) suffix of another.

AnsiEndsText function

Indicates whether one string is a (case-insensitive) suffix of another.

AnsiExtractQuotedStr function

Converts a quoted string into an unquoted string.

AnsiIndexStr function

Provides the index of a specified string in an array of strings.

AnsiIndexText function

Provides the index of a specified string in an array of strings.

AnsiLeftStr function

Returns the substring of a specified length that appears at the start of a string.

AnsiLowerCase function

Returns a string that is a copy of the given string converted

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约