本文整理汇总了Java中org.apache.oro.text.perl.Perl5Util.match方法的典型用法代码示例。如果您正苦于以下问题:Java Perl5Util.match方法的具体用法?Java Perl5Util.match怎么用?Java Perl5Util.match使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.oro.text.perl.Perl5Util
的用法示例。
在下文中一共展示了Perl5Util.match方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isValidAuthorityHostNoDot
import org.apache.oro.text.perl.Perl5Util; //导入方法依赖的package包/类
/**
* Check if the authority contains a valid hostname without "."
* characters and an optional port number
*
* @param authority
* @return <code>true</code> if the authority is valid
*/
private boolean isValidAuthorityHostNoDot(String authority) {
Perl5Util authorityMatcher = new Perl5Util();
if (authority != null
&& authorityMatcher.match(
"/^([a-zA-Z\\d\\-\\.]*)(:\\d*)?(.*)?/", authority)) {
String hostIP = authorityMatcher.group(1);
if (hostIP.indexOf('.') < 0) {
// the hostname contains no dot, add domain validation to check invalid hostname like "g08fnstd110825-"
DomainValidator domainValidator = DomainValidator.getInstance(true);
if(!domainValidator.isValid(hostIP)) {
return false;
}
String port = authorityMatcher.group(2);
if (!isValidPort(port)) {
return false;
}
String extra = authorityMatcher.group(3);
return GenericValidator.isBlankOrNull(extra);
} else {
return false;
}
} else {
return false;
}
}
示例2: isValidPort
import org.apache.oro.text.perl.Perl5Util; //导入方法依赖的package包/类
private boolean isValidPort(String port) {
if (port != null) {
Perl5Util portMatcher = new Perl5Util();
if (!portMatcher.match("/^:(\\d{1,5})$/", port))
return false;
}
return true;
}
示例3: isValidAuthorityHostNoTld
import org.apache.oro.text.perl.Perl5Util; //导入方法依赖的package包/类
/**
* Check if the authority contains a hostname without top level domain
* and an optional port number
*
* @param authority
* @return <code>true</code> if the authority is valid
*/
private boolean isValidAuthorityHostNoTld(String authority) {
Perl5Util authorityMatcher = new Perl5Util();
if (authority != null
&& authorityMatcher.match(
"/^([a-zA-Z\\d\\-\\.]*)(:\\d*)?(.*)?/", authority)) {
String host = authorityMatcher.group(1);
if (host.indexOf('.') > 0) {
DomainValidator domainValidator = DomainValidator.getInstance();
// Make the host have a valid TLD, so that the "no TLD" host can pass the domain validation.
String patchedHost = host + ".com";
if(!domainValidator.isValid(patchedHost)) {
return false;
}
String port = authorityMatcher.group(2);
if (!isValidPort(port)) {
return false;
}
String extra = authorityMatcher.group(3);
return GenericValidator.isBlankOrNull(extra);
} else {
return false;
}
} else {
return false;
}
}
示例4: convertTemplate
import org.apache.oro.text.perl.Perl5Util; //导入方法依赖的package包/类
/**
* Apply find/replace regexes to our WM template
*/
public String convertTemplate(String template)
{
String contents = StringUtils.fileContentsToString(template);
// Overcome Velocity 0.71 limitation.
// HELP: Is this still necessary?
if (!contents.endsWith("\n"))
{
contents += "\n";
}
// Convert most markup.
Perl5Util perl = new Perl5Util();
for (int i = 0; i < perLineREs.length; i += 2)
{
contents = perl.substitute(makeSubstRE(i), contents);
}
// Convert closing curlies.
if (perl.match("m/javascript/i", contents))
{
// ASSUMPTION: JavaScript is indented, WM is not.
contents = perl.substitute("s/\n}/\n#end/g", contents);
}
else
{
contents = perl.substitute("s/(\n\\s*)}/$1#end/g", contents);
contents = perl.substitute("s/#end\\s*\n\\s*#else/#else/g",
contents);
}
return contents;
}
示例5: accept
import org.apache.oro.text.perl.Perl5Util; //导入方法依赖的package包/类
public boolean accept(File file) {
String filename = file.getName();
Perl5Util perl5Util = new Perl5Util();
if (perl5Util.match("/(?:(\\d+)(?:_(\\d+))?)(?:_se|\\.(.*))?/", filename)) {
String idStr = perl5Util.group(1);
String variantName = FileUtility.unescapeFilename(StringUtils.defaultString(perl5Util.group(3)));
String docVersionNo = perl5Util.group(2);
return accept(file,
Integer.parseInt(idStr),
docVersionNo == null ? 0 : Integer.parseInt(docVersionNo),
variantName);
}
return false;
}
示例6: matchesUrl
import org.apache.oro.text.perl.Perl5Util; //导入方法依赖的package包/类
boolean matchesUrl(Perl5Util perl5Util,
PatternMatcherInput patternMatcherInput) {
String urlWithoutSchemePattern = "[^\\s\"'()]+";
return perl5Util.match("m,\\bhttp://" + urlWithoutSchemePattern + "|\\bhref=[\"']?("
+ urlWithoutSchemePattern
+ "),i", patternMatcherInput);
}
示例7: getUrl
import org.apache.oro.text.perl.Perl5Util; //导入方法依赖的package包/类
public String getUrl() {
Perl5Util regexp = new Perl5Util();
if (!regexp.match("m!^\\w+:|^[/.]!", url)) {
String scheme = "http";
if (url.toLowerCase().startsWith("ftp.")) {
scheme = "ftp";
}
return scheme + "://" + url;
}
return url;
}