谢谢~!

解决方案 »

  1.   

    1,先根据空格,分成N个单词,放到TSTRINGLIST中;
    2,现在可以得到了
      

  2.   

    for i:=1 to Length(s-1) do
      if s[i]=' ' then
        ShowMessage(s[i+1]);
      

  3.   

    for i:=1 to Length(s-1) do
      if (s[i]=' ') AND (s[i+1] <> ' ') then
        ShowMessage(s[i+1]);
      

  4.   

    POS来得到每个单词的首位位置
    COPY来得到每个单词的第一个字母
      

  5.   

    分割字符串!!!!!!!
    给出实例如下:
    type
      TResultArray = array of string;function SplitString(const source, ch: string): TResultArray;
    var
      temp: string;
      i: integer;
    begin
      temp := source;
      i := pos(ch, source);
      while i <> 0 do
      begin
        SetLength(Result, Length(Result) + 1);
        Result[Length(Result) - 1] := copy(temp, 0, i - 1);
        delete(temp, 1, i);
        i := pos(ch, temp);
      end;
      SetLength(Result, Length(Result) + 1);
      Result[Length(Result)-1] := Temp;
    end;
    **************
    function SplitString(const source,ch:string):tstringlist;
    var
     temp:string;
     i:integer;
    begin
     result:=tstringlist.Create;
     temp:=source;
     i:=pos(ch,source);
     while i<>0 do
     begin
       result.Add(copy(temp,0,i-1));
       delete(temp,1,i);
       i:=pos(ch,temp);
     end;
     result.Add(temp);
    end;
    调用:
    s:=splitstring('afsdfsdaaa|bbfdsfsdb|ccc','|');
    for i:=0 to s.Count-1 do
     b:=b+s.Strings[i]+#13;
    showmessage(b);
    s.free;
      

  6.   

    POS查找空格的位置,找到每个单词的首位位置。就好办了。
      

  7.   

    POS查找空格的位置,把每个单词放在TStingList里
    用copy 取:
    var
      TStrList : TStringList;
      Str : String;
    begin
      TStrList := TStringList.Create;
      TStrList.Clear;
      if Str <> '' then
      begin
        i := pos(',',str);
        while i > 0 do
        begin
          Tmp := copy(Str,1,i - 1);
          TStrList.Add(Tmp);
          Str := copy(Str,i + 1,length(Str)-i);
          i := pos(',',Str);
        end;
        if Str <> '' then
        begin
          TStrList.Add(Str);
        end;
      end;
    end;
      

  8.   

    var
      slist:TStringList;
      s: String;
      i: Integer;slist:=TStringList.Create;
    slist.DelimitedText := s;
    slist.Delimiter := ' ';
    for i=0 to slist.Count-1 do
      ShowMessage(slist.Strings[i][1]);
      

  9.   

    Var
       s, s1, s2, ss: string;
       i, j: integer;
    begin
         //s:='has sent you an e-greeting card';
         i:= ansipos(' ',s);
         if (i<>1) and (s<>'') then
            ss:= copy(s,1,1);
         while i<>0 do
         begin
              if i<>length(s) then    //判断你的字符串的最后一个字符是否为空格
              begin
                   s1:=copy(s,i+1,1);
                   ss:=ss + s1;
                   s :=copy(s,i+1,length(s)-i);
                   i :=ansipos(' ',s);
              end;
         end;
    end;
      

  10.   

    利用pos('',string)和delete函数即可解决