Webシステム開発の雑多なアウトプット

AWS、プログラム、OSS等を中心に良かった本も。

【Talend (Java)】Perl5Matcher と Perl5Compiler

tLibraryLoad で下記jarを指定。
jakarta-oro-2.0.8.jar

OnSubjebOK で tJava へ結ぶ。

import org.apache.oro.text.regex.MalformedPatternException;
import org.apache.oro.text.regex.Pattern;
import org.apache.oro.text.regex.Perl5Compiler;
import org.apache.oro.text.regex.Perl5Matcher;

String email="info@talend.com";

Perl5Matcher matcher = new Perl5Matcher();
Perl5Compiler compiler = new Perl5Compiler();
Pattern pattern=compiler.compile("^[\\w_.-]+@[\\w.-]+\\.[\\w]+$");
if(matcher.matches(email,pattern)) {
    System.out.println(email + " is a correct email address");}
else{
    System.err.println(email + " is an incorrect email address");
}



Perl5Matcherクラス

public boolean matches(java.lang.String input, Pattern pattern)

 文字列が、あるパターンに厳密にマッチしているかどうかを判定します。

Perl5Compilerクラス

public static final java.lang.String quotemeta(java.lang.String expression)

 文字列が渡された時に、元の文字列の各文字を文字通りに解釈するPerl5 正規表現を返却します。