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 中文大写日期转换函数

Delphi 实现透明窗体

Delphi 系统对话框(如浏览目录)被隐藏到主窗体后面造成程序无法操作的临时处理方式

Delphi http远程屏幕源码

Delphi 中的文件系统进行unicode标准化

Delphi 对txt文件的操作

Delphi xe 利用fmx控件的makescreenshot过程实现wait效果

Delphi xe5 使用 android 内置函数几个小测试

Delphi 获取带分隔符字符串中的字段值

Delphi ^ 符号的特殊用法

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



打赏

取消

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

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

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

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

评论

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