掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
'1,234.56abc789'から'1,234.56'を取り出す (ID:32607)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
文字列の左から小数点、カンマ、数字のみを取り出し, 初めて非数字に出会うまでの文字列を取り出す関数を作っています。 愚直に書きますと↓ function TForm1.Suji(S: string): string; var i:integer; begin for i:=0 to length(S) do begin if S[i]='0' then Result:=Result+S[i]; if S[i]='1' then Result:=Result+S[i]; if S[i]='2' then Result:=Result+S[i]; if S[i]='3' then Result:=Result+S[i]; if S[i]='4' then Result:=Result+S[i]; if S[i]='5' then Result:=Result+S[i]; if S[i]='6' then Result:=Result+S[i]; if S[i]='7' then Result:=Result+S[i]; if S[i]='8' then Result:=Result+S[i]; if S[i]='9' then Result:=Result+S[i]; if S[i]='.' then Result:=Result+S[i]; if S[i]=',' then Result:=Result+S[i]; end; end; となりそうですが、これだと'789'まで取ってきそうです。 簡潔な記法を教えて下さい。(初歩的な質問ですみません))
←解決時は質問者本人がここをチェックしてください。
更新する
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.