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()

  • 相关阅读:
    设计模式之适配器模式
    设计模式之装饰者模式
    设计模式之原型模式
    【转】SQL Server中的事务与锁
    【转修正】sql server行版本控制的隔离级别
    【转】数据库系统异常排查之DMV
    【转】SQLServerDBA十大必备工具---让生活轻松点
    Jekens 配置多项目SCM GitLab+Jenkins持续集成环境
    Jekens Source Code Management None 源码管理没有Git
    Spring容器事件、自定义事件
  • 原文地址:https://www.cnblogs.com/michellexiaoqi/p/7387690.html
Copyright © 2011-2022 走看看