⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 regexreplacementtextfiltertest.java

📁 一个jsp网页布局框架
💻 JAVA
字号:
package com.opensymphony.module.sitemesh.html.rules;import junit.framework.TestCase;import java.io.Reader;import java.io.StringReader;import java.io.Writer;import java.io.StringWriter;import java.io.IOException;import com.opensymphony.module.sitemesh.html.HTMLProcessor;public class RegexReplacementTextFilterTest extends TestCase {    public void testReplacesTextContentMatchedByRegularExpression() throws IOException {        Reader in = new StringReader("<hello>Today is DATE so hi</hello>");        Writer out = new StringWriter();        HTMLProcessor processor = new HTMLProcessor(in, out);        processor.addTextFilter(new RegexReplacementTextFilter("DATE", "1-jan-2009"));        processor.process();        assertEquals("<hello>Today is 1-jan-2009 so hi</hello>", out.toString());    }    public void testAllowsMatchedGroupToBeUsedInSubsitution() throws IOException {        Reader in = new StringReader("<hello>I think JIRA:SIM-1234 is the way forward</hello>");        Writer out = new StringWriter();        HTMLProcessor processor = new HTMLProcessor(in, out);        processor.addTextFilter(new RegexReplacementTextFilter(                "JIRA:([A-Z]+\\-[0-9]+)",                "<a href='http://jira.opensymhony.com/browse/$1'>$1</a>"));        processor.process();        assertEquals(                "<hello>I think <a href='http://jira.opensymhony.com/browse/SIM-1234'>SIM-1234</a> is the way forward</hello>",                out.toString());    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -