Delphi 2009 new Unit character[2]

Source: Internet
Author: User

Isletter, Isupper, Islower, IsDigit, Isnumber

IsLetter: {是否是个字母; 范围 A..Z 与 a..z}
IsUpper: {是否是个大写字母; 范围 A..Z}
IsLower: {是否是个小写字母; 范围 a..z}
IsDigit: {是否是个十进制数字; 范围 0..9}
IsNumber: {是否是个数字符号; 范围包括 0..9, 还有 ASCII 码中的 178、179、185、188、189、190 等}

Test code:

Unit Unit1;
Interface
Uses
Windows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms,
Dialogs, Stdctrls;
Type
TForm1 = Class (Tform)
Button1:tbutton;
Button2:tbutton;
Button3:tbutton;
Button4:tbutton;
Button5:tbutton;
Procedure Button1Click (Sender:tobject);
Procedure Button2click (Sender:tobject);
Procedure Button3click (Sender:tobject);
Procedure Button4click (Sender:tobject);
Procedure Button5click (Sender:tobject);
End
Var
Form1:tform1;
Implementation
{$R *.DFM}
Uses Character;
{isletter: Whether it is a letter}
Procedure Tform1.button1click (Sender:tobject);
Var
B1,b2,b3:boolean;
Begin
B1: = Isletter (' A '); Is
B2: = Isletter (' a '); Is
B3: = Isletter (' 9 '); Whether
SHOWMESSAGEFMT ('%s,%s,%s ', [Booltostr (B1,true), Booltostr (B2,true), Booltostr (b3,true)]);
{True,true,false}
B1: = Isletter (' D2009 ', 1);
B2: = Isletter (' D2009 ', 2);
SHOWMESSAGEFMT ('%s,%s ', [Booltostr (B1,true), Booltostr (b2,true)]);
{True,false}
End
{isupper: is a capital letter}
Procedure Tform1.button2click (Sender:tobject);
Var
B1,b2,b3:boolean;
Begin
B1: = Isupper (' A '); Is
B2: = Isupper (' a '); Whether
B3: = Isupper (' 9 '); Whether
SHOWMESSAGEFMT ('%s,%s,%s ', [Booltostr (B1,true), Booltostr (B2,true), Booltostr (b3,true)]);
{True,false,false}
B1: = Isupper (' Delphi ', 1);
B2: = Isupper (' Delphi ', 2);
SHOWMESSAGEFMT ('%s,%s ', [Booltostr (B1,true), Booltostr (b2,true)]);
{True,false}
End
{islower: is a lowercase letter}
Procedure Tform1.button3click (Sender:tobject);
Var
B1,b2,b3:boolean;
Begin
B1: = Islower (' A '); Whether
B2: = Islower (' a '); Is
B3: = Islower (' 9 '); Whether
SHOWMESSAGEFMT ('%s,%s,%s ', [Booltostr (B1,true), Booltostr (B2,true), Booltostr (b3,true)]);
{False,true,false}
B1: = Islower (' Delphi ', 1);
B2: = Islower (' Delphi ', 2);
SHOWMESSAGEFMT ('%s,%s ', [Booltostr (B1,true), Booltostr (b2,true)]);
{False,true}
End
{isdigit: is a decimal digit}
Procedure Tform1.button4click (Sender:tobject);
Var
B1,b2,b3:boolean;
Begin
B1: = IsDigit (' A '); Whether
B2: = IsDigit (' ½ '); Whether
B3: = isdigit (' 9 '); Is
SHOWMESSAGEFMT ('%s,%s,%s ', [Booltostr (B1,true), Booltostr (B2,true), Booltostr (b3,true)]);
{False,false,true}
B1: = IsDigit (' D2009 ', 1);
B2: = IsDigit (' D2009 ', 2);
SHOWMESSAGEFMT ('%s,%s ', [Booltostr (B1,true), Booltostr (b2,true)]);
{False,true}
End
{isnumber: is a numeric symbol}
Procedure Tform1.button5click (Sender:tobject);
Var
B1,b2,b3:boolean;
Begin
B1: = Isnumber (' A '); Is
B2: = Isnumber (' ½ '); Is
B3: = Isnumber (' 9 '); Whether
SHOWMESSAGEFMT ('%s,%s,%s ', [Booltostr (B1,true), Booltostr (B2,true), Booltostr (b3,true)]);
{False,true,true}
B1: = Isnumber (' 123¹²³¼½¾ ', 1);
B2: = Isnumber (' 123¹²³¼½¾ ', 4); {All 9 characters here are compound}
SHOWMESSAGEFMT ('%s,%s ', [Booltostr (B1,true), Booltostr (b2,true)]);
{True,true}
End
End.

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.