截取字符(pos,copy,Leftstr,MidStr,RightStr)以逗号为准把字符串拆分,判断字符串是否有数字、字母(大小写), 去掉字符串空格

1、copy(a,b,c)

举个例子:

str := “123456”;str1 := Copy(Str,2,3);结果就是 str1 等于 234。Copy有3个参数,第一个是你要处理的字符串,第二个是你要截取的开始位置,第3个是截取位数。当你的第3个参数大于字符长度,那么效果就是取 开始位置 后的所有字符。str1 := Copy(Str,2,10); 结果就是str1 等于 23456。

 2、pos(a,b);

     取出子串a,在父串b中第一次出现的位置;

     例如:

     pos(‘b’,‘abcd’);

     返回结果是2;

S := ’Delphi is the BEST’, 那么 
3、LeftStr(S, 5) := ’Delph’ //即S前5位字符
4、MidStr(S, 6, 7) := ’i-is-th’// 即s的第六位开始后面7个字符(-:=空格)
5、RightStr(S, 6) := ’e-BEST’//即S后面的字符(-:=空格)

delphi 怎么能以逗号为准把字符串拆分

var
stl:Tstringlist;
s:string;
i:integer;
begin
s:='1,2,3,4';
stl:= Tstringlist.Create();
stl.Delimiter:=',';
stl.CommaText:=s;
for i:=0 to stl.Count-1 do
begin
showmessage((stl.Strings[i]));
end;

end;

delphi 判断字符串字母,数字

sexpr :=Svdevobj.GetValue('expr').Value;
edt_expr.Text:=sexpr;
for i:=0 to Length(sexpr)-1 do
begin
  if (not (sexpr[i] in ['A'..'Z'])) or (not (sexpr[i] in ['a'..'z']))  or (not (sexpr[i] in [‘0'..'9'])) then //如果Vaule的第i个字不是A-Z或者a-z或0-9中的任一个

  begin

    result:=false; //返回值 不是(假)

    Exit;
  end;

end;

delphi 去掉空格

Trim()
TrimRight()
TrimLeft()

原文地址:https://www.cnblogs.com/michellexiaoqi/p/7387690.html