Delphi regular expression syntax (3): matching range

Source: Internet
Author: User
// [A-Z]: match all uppercase letters var REG: tperlregex; begin REG: = tperlregex. create (NiL); Reg. subject: = 'codegear Delphi 2007 for Win32 '; Reg. regEx: = '[A-Z]'; Reg. replacement: = '◆ '; Reg. replaceall; showmessage (Reg. subject); // return: ◆ ode ◆ ear ◆ elphi 2007 for ◆ in32 freeandnil (REG); end;
  
   
 // [A-Z]: match all lowercase letters var REG: tperlregex; begin REG: = tperlregex. create (NiL); Reg. subject: = 'codegear Delphi 2007 for Win32 '; Reg. regEx: = '[A-Z]'; Reg. replacement: = '◆ '; Reg. replaceall; showmessage (Reg. subject); // return: C ◆ 2007 ◆ W ◆ 32 freeandnil (REG); end;
  
   
 // [0-9]: Match All numbers var REG: tperlregex; begin REG: = tperlregex. create (NiL); Reg. subject: = 'codegear Delphi 2007 for Win32 '; Reg. regEx: = '[0-9]'; Reg. replacement: = '◆ '; Reg. replaceall; showmessage (Reg. subject); // return: codegear Delphi ◆ for win ◆ freeandnil (REG); end;
  
   
 // Match the following range: var REG: tperlregex; begin REG: = tperlregex. create (NiL); Reg. subject: = 'codegear Delphi 2007 for Win32 '; Reg. regEx: = '[C-Do-p0-2]'; // upper case: C-D; lower case: O-P; number: 0-2 Reg. replacement: = '◆ '; Reg. replaceall; showmessage (Reg. subject); // return: ◆ degear ◆ El ◆ Hi ◆ 7 f ◆ R win3 ◆ freeandnil (REG); end;
  
   
 // Match all var REG: tperlregex; begin REG: = tperlregex in. create (NiL); Reg. subject: = 'codegear Delphi 2007 for Win32 '; Reg. regEx: = '[CI2]'; // uppercase letter: C; lowercase letter: I; number: 2 Reg. replacement: = '◆ '; Reg. replaceall; showmessage (Reg. subject); // return: ◆ odegear Delph ◆ 007 for W ◆ N3 ◆ freeandnil (REG); end;
  
   
 // ^ Exclude all var REG: tperlregex; begin REG: = tperlregex in. create (NiL); Reg. subject: = 'codegear Delphi 2007 for Win32 '; Reg. regEx: = '[^ Ci0-2]'; // upper-case letters: C; lower-case letters: I; digits: 0-2 Reg. replacement: = '◆ '; Reg. replaceall; showmessage (Reg. subject); // return: C ◆ I ◆ 200 ◆ I ◆ 2 freeandnil (REG ); 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.