Delphi extracts a number from a character

Source: Internet
Author: User

Function Setstring (cstring:string): string; {Extract Number}
Var
I:integer;
str:string;
Begin
Str:= ";
For i:=1 to Length (cString) does
Begin
If Pos (Cstring[i], ' 0123456789. ') <=0 Then
Break
Else
Case Cstring[i] of
'. ': str:=str+ '. ';

' 0 ': str:=str+ ' 0 '; ' 1 ': str:=str+ ' 1 '; ' 2 ': str:=str+ ' 2 ';
' 3 ': str:=str+ ' 3 '; ' 4 ': str:=str+ ' 4 '; ' 5 ': str:=str+ ' 5 ';
' 6 ': str:=str+ ' 6 '; ' 7 ': str:=str+ ' 7 ';
' 8 ': str:=str+ ' 8 '; ' 9 ': str:=str+ ' 9 ';
End
End
SETSTRING:=STR;
End

If 121545adfdf.121 is extracted after the break command is removed from the 121545 function, the result is: 121545.121

Delphi extracts a number from a character

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.