Delphi 提取字符串中所有数字


本文整理自网络,侵删。

 
unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

uses System.Character;

function getNumberFromStr(strIn: string): string;
var
  i: integer;
  tempStr: string;
begin
  tempStr := '';

  if Length(strIn) = 0 then
  begin
    Result := '';
    exit;
  end;

  for i := 1 to strIn.Length do
  begin

    if IsNumber(strIn[i]) then    //isNumber--System.Character
    begin
      tempStr := tempStr + strIn[i];
    end;
  end;

  Result := tempStr;
end;



procedure TForm1.FormCreate(Sender: TObject);
begin
   caption:=getNumberFromStr('abc123456 789789');
end;

end.

相关阅读 >>

Delphi点击网页弹出的alert对话框的确定按钮

Delphi 用webbrowser给要访问的页面加上referer(来路)参数

Delphi 小数点四舍五入问题

tstringgrid 添加鼠标拖动功能

Delphi中实现磁盘信息类(tdriveinfo)

Delphi xe中windows7新的taskbar功能的使用

Delphi 写变速齿轮外挂

Delphi xe6 取得app自己的版本号(横跨4个平台)

Delphi 字节数转换为kb或mb字符串

Delphi jpg和bitmap互转转换的方法

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...