Author: bayard Date: Mon Jul 13 06:46:33 2009 New Revision: 793471 URL: http://svn.apache.org/viewvc?rev=793471&view=rev Log: Some functions added from Lang, and a pair of regex functions added to offer improved replacement
Added: jakarta/taglibs/sandbox/extended/trunk/src/main/java/org/apache/taglibs/extended/RegexFunction.java (with props) Modified: jakarta/taglibs/sandbox/extended/trunk/src/main/resources/META-INF/tlds/taglibs-extended.tld Added: jakarta/taglibs/sandbox/extended/trunk/src/main/java/org/apache/taglibs/extended/RegexFunction.java URL: http://svn.apache.org/viewvc/jakarta/taglibs/sandbox/extended/trunk/src/main/java/org/apache/taglibs/extended/RegexFunction.java?rev=793471&view=auto ============================================================================== --- jakarta/taglibs/sandbox/extended/trunk/src/main/java/org/apache/taglibs/extended/RegexFunction.java (added) +++ jakarta/taglibs/sandbox/extended/trunk/src/main/java/org/apache/taglibs/extended/RegexFunction.java Mon Jul 13 06:46:33 2009 @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.taglibs.extended; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Provides regular expression based methods to the EL + */ +public class RegexFunction { + + /** + * Run a regex replace on the first match in the input String. + * Akin to java.lang.String.replaceFirst + */ + public static String replaceFirst(String input, String regex, String with) { + return input.replaceFirst(regex, with); + } + + /** + * Run a regex replace on the all matches in the input String. + * Akin to java.lang.String.replaceAll + */ + public static String replaceAll(String input, String regex, String with) { + return input.replaceAll(regex, with); + } + +} Propchange: jakarta/taglibs/sandbox/extended/trunk/src/main/java/org/apache/taglibs/extended/RegexFunction.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: jakarta/taglibs/sandbox/extended/trunk/src/main/resources/META-INF/tlds/taglibs-extended.tld URL: http://svn.apache.org/viewvc/jakarta/taglibs/sandbox/extended/trunk/src/main/resources/META-INF/tlds/taglibs-extended.tld?rev=793471&r1=793470&r2=793471&view=diff ============================================================================== --- jakarta/taglibs/sandbox/extended/trunk/src/main/resources/META-INF/tlds/taglibs-extended.tld (original) +++ jakarta/taglibs/sandbox/extended/trunk/src/main/resources/META-INF/tlds/taglibs-extended.tld Mon Jul 13 06:46:33 2009 @@ -39,5 +39,65 @@ java.lang.String capitalize(java.lang.String) </function-signature> </function> + <function> + <name>lastIndexOf</name> + <function-class>org.apache.commons.lang.StringUtils</function-class> + <function-signature> + int lastIndexOf(java.lang.String, java.lang.String) + </function-signature> + </function> + <function> + <name>left</name> + <function-class>org.apache.commons.lang.StringUtils</function-class> + <function-signature> + java.lang.String left(java.lang.String, int) + </function-signature> + </function> + <function> + <name>mid</name> + <function-class>org.apache.commons.lang.StringUtils</function-class> + <function-signature> + java.lang.String mid(java.lang.String, int) + </function-signature> + </function> + <function> + <name>right</name> + <function-class>org.apache.commons.lang.StringUtils</function-class> + <function-signature> + java.lang.String right(java.lang.String, int) + </function-signature> + </function> + <function> + <name>repeat</name> + <function-class>org.apache.commons.lang.StringUtils</function-class> + <function-signature> + java.lang.String repeat(java.lang.String, int) + </function-signature> + </function> + + <!-- Commons Lang WordUtils functions --> + <function> + <name>capitalizeAllWords</name> + <function-class>org.apache.commons.lang.WordUtils</function-class> + <function-signature> + java.lang.String capitalize(java.lang.String) + </function-signature> + </function> + + <!-- Defined in this Taglib --> + <function> + <name>replaceAll</name> + <function-class>org.apache.taglibs.extended.RegexFunction</function-class> + <function-signature> + java.lang.String replaceAll(java.lang.String, java.lang.String, java.lang.String) + </function-signature> + </function> + <function> + <name>replaceFirst</name> + <function-class>org.apache.taglibs.extended.RegexFunction</function-class> + <function-signature> + java.lang.String replaceFirst(java.lang.String, java.lang.String, java.lang.String) + </function-signature> + </function> </taglib> --------------------------------------------------------------------- To unsubscribe, e-mail: taglibs-dev-unsubscr...@jakarta.apache.org For additional commands, e-mail: taglibs-dev-h...@jakarta.apache.org