zoukankan      html  css  js  c++  java
  • 截取字符(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()

  • 相关阅读:
    字节
    服务器每个网站占用资源
    in exists 条件查询
    NUnit2.0详细使用方法
    敏捷方法之极限编程(XP)和 Scrum区别
    学习内容及计划
    关于查看网页源文件不显示源代码(打开的是桌面文件夹)的问题
    用JS取float型 小数点 后两位
    [转]什么是CMMI?
    六月新版微软一站式示例代码库发布 新增20个Windows示例代码
  • 原文地址:https://www.cnblogs.com/michellexiaoqi/p/7387690.html
Copyright © 2011-2022 走看看