zoukankan      html  css  js  c++  java
  • 取代有规律的字符

    function SplitStr(pSource: string; OldStr: string; SpliChar: Char): string;
    var
      s: string;
      strList: TStrings;
      i: Integer;
      iPos: Integer;
      sPos: string;
    begin
      Result := '';
      strList := TStringList.Create;
    
      s := StringReplace(pSource, OldStr, SpliChar, [rfReplaceAll, rfIgnoreCase]);
      ExtractStrings([SpliChar], [], PChar(s), strList);
      for i := 0 to strList.Count - 1 do
      begin
        sPos := strList.Strings[i];
        if sPos[1] = '''' then {如果第一个字符为 ' }
        begin
          Delete(sPos, 1, 1); { 删除第一个 ' }
          iPos := Pos('''', sPos);
          if iPos <> 0 then { 查找第二个 ' }
          begin
            sPos := '''%' + StringReplace(sPos, '''', '%''', []);
            sPos := OldStr + sPos; {还原 'like ' 这个字符}
          end;
        end;
        Result := Result + sPos;
      end;
    
    
      strList.Free;{出来混总是要还的}
    end;
    
    {调用例子}
    begin
      Edit2.Text := SplitStr(Edit1.Text, 'like ', '#');
    end;
    
  • 相关阅读:
    算法第二章上机实践报告
    算法第一章作业
    第7章学习小结 不使用STL-map过实践题:QQ帐户的申请与登陆
    第6章学习小结
    HDU
    HDU 2089 不要62(数位DP)
    char-2
    chart-7
    chart-6
    char-8
  • 原文地址:https://www.cnblogs.com/sail2000/p/1773416.html
Copyright © 2011-2022 走看看