本文整理汇总了Java中org.apache.oro.text.perl.Perl5Util.substitute方法的典型用法代码示例。如果您正苦于以下问题:Java Perl5Util.substitute方法的具体用法?Java Perl5Util.substitute怎么用?Java Perl5Util.substitute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.oro.text.perl.Perl5Util
的用法示例。
在下文中一共展示了Perl5Util.substitute方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeOroPattern
import org.apache.oro.text.perl.Perl5Util; //导入方法依赖的package包/类
public static Pattern makeOroPattern(String sqlLike) {
Perl5Util perl5Util = new Perl5Util();
try {
sqlLike = perl5Util.substitute("s/([$^.+*?])/\\\\$1/g", sqlLike);
sqlLike = perl5Util.substitute("s/%/.*/g", sqlLike);
sqlLike = perl5Util.substitute("s/_/./g", sqlLike);
} catch (Throwable t) {
String errMsg = "Error in ORO pattern substitution for SQL like clause [" + sqlLike + "]: " + t.toString();
Debug.logError(t, errMsg, module);
throw new IllegalArgumentException(errMsg);
}
try {
return PatternFactory.createOrGetPerl5CompiledPattern(sqlLike, true);
} catch (MalformedPatternException e) {
Debug.logError(e, module);
}
return null;
}
示例2: 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;
}
示例3: removeTags
import org.apache.oro.text.perl.Perl5Util; //导入方法依赖的package包/类
public static String removeTags(String html) {
Perl5Util perl5util = new Perl5Util();
return perl5util.substitute("s!<.+?>!!g", html);
}
示例4: substitute
import org.apache.oro.text.perl.Perl5Util; //导入方法依赖的package包/类
/**
* Method that performs a regular expression substitution function.
* @param originalString the string that this method will operate on
* @param regularExpression the s/// substitution regular expression
* operation to perform on orignalString
* @return the result of performing the s/// operation on originalString
*/
private String substitute(String originalString,
String regularExpression) {
Perl5Util perlUtil = new Perl5Util();
String result = perlUtil.substitute(regularExpression, originalString);
return result;
}