// \ D matches all numbers, which is equivalent to [0-9] var REG: tperlregex; begin REG: = tperlregex. create (NiL); Reg. subject: = 'expect Delphi 2008 for Win32! '; Reg. regEx: = '\ d'; Reg. replacement: = '◆ '; Reg. replaceall; showmessage (Reg. subject); // return: looking forward to Delphi ◆ for win ◆! Freeandnil (REG); end;
// \ D matches all non-numbers, which is equivalent to [^ 0-9] var REG: tperlregex; begin REG: = tperlregex. create (NiL); Reg. subject: = 'expect Delphi 2008 for Win32! '; Reg. regEx: = '\ d'; Reg. replacement: = '◆ '; Reg. replaceall; showmessage (Reg. subject); // return: ◆ 2008 ◆ 32 ◆ freeandnil (REG); end;
// \ W matches letters, numbers, and underscores (_), which are equivalent to [A-Za-z0-9 _] var REG: tperlregex; begin REG: = tperlregex. create (NiL); Reg. subject: = 'expect Delphi 2008 for Win32! '; Reg. regEx: = '\ W'; Reg. replacement: = '◆ '; Reg. replaceall; showmessage (Reg. subject); // return: Expected ◆! Freeandnil (REG); end;
// \ W match non-letters, numbers and underscores _, equivalent to [^ A-Za-z0-9 _] var REG: tperlregex; begin REG: = tperlregex. create (NiL); Reg. subject: = 'expect Delphi 2008 for Win32! '; Reg. regEx: = '\ W'; Reg. replacement: = '◆ '; Reg. replaceall; showmessage (Reg. subject); // return: ◆ Delphi ◆ 2008 ◆ for ◆ Win32 ◆ freeandnil (REG); end;
// \ S matches any blank spaces, including spaces, tabulation, and page feed. It is equivalent to [\ f \ n \ r \ t \ v] var REG: tperlregex; begin REG: = tperlregex. create (NiL); Reg. subject: = 'expect Delphi 2008 for Win32! '; Reg. regEx: = '\ s'; Reg. replacement: = '◆ '; Reg. replaceall; showmessage (Reg. subject); // return: Expected Delphi ◆ 2008 ◆ for ◆ Win32! Freeandnil (REG); end; {\ f: linefeed \ n: linefeed \ r: Carriage Return \ t: tab (Tab) \ V: vertical tab}
// \ S matches any non-blank space, which is equivalent to [^ \ f \ n \ r \ t \ v] var REG: tperlregex; begin REG: = tperlregex. create (NiL); Reg. subject: = 'expect Delphi 2008 for Win32! '; Reg. regEx: = '\ s'; Reg. replacement: = '◆ '; Reg. replaceall; showmessage (Reg. subject); // return: ◆ freeandnil (REG); end;
// \ X matches the hexadecimal asciivar REG: tperlregex; begin REG: = tperlregex. create (NiL); Reg. subject: = 'codegear Delphi '; Reg. regEx: = '\ x61'; // the ASCII value of A is 97, that is, the hexadecimal 61 Reg. replacement: = '◆ '; Reg. replaceall; showmessage (Reg. subject); // return: codege ◆ R Delphi freeandnil (REG); end; // unfortunately, tperlregex cannot use \ U or \ U to match Unicode characters!
//. Match any character except the line break var REG: tperlregex; begin REG: = tperlregex. create (NiL); Reg. subject: = 'Expect '+ #10 + 'delphi 2008 for Win32! '; // #10 is the linefeed Reg. regEx: = '. '; Reg. replacement: = '◆ '; Reg. replaceall; showmessage (Reg. subject); {return result: ◆} freeandnil (REG ); end;