掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
Trim関数で大文字スペースもTrim対象にしたい (ID:14319)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
//自分で関数を作るのが一番早いんじゃないでしょうか const ZenkakuSpace = ' '; function MBTrimRight(s : string) : string; var i : Integer; begin i := Length(s); while i >= 1 do begin case ByteType(s,i) of mbSingleByte: if s[i] > #$20 then Break; mbLeadByte: Break; mbTrailByte: if (s[i] = ZenkakuSpace[2]) and (s[i-1] = ZenkakuSpace[1]) then Dec(i) else Break; end; Dec(i); end; Result := Copy(s,1,i); end; function MBTrimLeft(s : string) : string; var i : Integer; begin i := 1; while i < Length(s) do begin case ByteType(s,i) of mbSingleByte: if s[i] > #$20 then Break; mbLeadByte: if (s[i] = ZenkakuSpace[1]) and (s[i+1] = ZenkakuSpace[2]) then Inc(i) else Break; mbTrailByte: Break; end; Inc(i); end; Result := Copy(s,i,MaxInt); end; function MBTrim(s : string) : string; begin Result := MBTrimLeft(MBTrimRight(s)); end;
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.