今天早上来自 Progress 的 PANS 电子邮件中显示了以下内容:
http://knowledgebase.progress.com/articles/Article/000039027?popup=true
以下示例显示了如何在 ABL 中使用正则表达式:
/*
* IN TESTING, THIS DOESN'T WORK WITH MY INSTALLATION OF VERSION 10.2B RHEL 6,
* BUT IT DOES WORK WITH VERSION 10.2B WINDOWS INSTALLATION
*
* THE ERROR RETURNED ON THE LINUX ENVIRONMENT IS:
* │Could not find class or interface Regex. (12886)
*/
USING System.Text.RegularExpressions.*.
DEFINE VARIABLE chaine AS CHARACTER NO-UNDO INIT "test@test.com".
DEFINE VARIABLE i AS INTEGER NO-UNDO.
DEFINE VARIABLE regexp AS CLASS Regex NO-UNDO.
regexp = NEW Regex("^[^\x00-\x1F^\(^\)^\<^\>^\@^\,^\;^\:^\\^\~"^\.^\[^\]^\s]+(\.[^\x00-\x1F^\(^\)^\<^\>^\@^\,^\;^\:^\\^\~"^\.^\[^\]^\s]+)*@([^\x00-\x1F^\(^\)^\<^\> ^\@^\,^\;^\:^\\^\~"^\.^\[^\]^\s]+(\.[^\x00-\x1F^\(^\)^\<^\>^\@^\,^\;^\:^\\^\~"^\.^\[^\]^\s]+))+$").
DO i = 1 TO 100:
IF regexp:IsMatch(chaine) THEN MESSAGE "OK".
ELSE MESSAGE "KO" .
END.
DELETE OBJECT regexp.
上面的代码示例专门针对 Windows。要在 UNIX(或 Linux)上使用正则表达式,您需要使用适用于该操作系统的相应库。可以在这里找到一个例子:
http://dbappraise.com/ppt/shlib.pptx