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响应wmi事件(响应网线断开)

Delphi 关于字符串的一些使用技巧

Delphi xe tparallel.for的用法

Delphi 怎么截取文件路径字符串,只保留文件名

Delphi filestream

Delphi idhttp使用代理ip

Delphi flash控件使用

Delphi 文件查找findfirst,findnext,findclose

Delphi 获取用户当前的windows临时文件夹

Delphi string.create(char,count)

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



打赏

取消

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

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

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

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

评论

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