Web page conversion of special characters, such as [image]

2011-01-02  来源:本站原创  分类:Java  人气:86 

package com.email.util;

public class BBCODE {

/ /
/ / [Img code = "1.jpg"] [img code = "2.jpg"]
/ / <img Src="1.jpg" /> <img src="2.jpg" />

public static String filter (String code) {

/ / Bold ...
code = code.replaceAll ("(\ \ [b \ \ ](.[^ \ \ []*)( \ \ [/ b \ \ ]))"," <strong> $ 2 </ strong> ");

/ / Line [b]
code = code.replaceAll ("\ \ [b \ \]", "<br />");

/ / Font ....
code = code.replaceAll ("(\ \ [size =(.*?) \ \ ])(.*?)( \ \ [\ \ / size \ \])", "<span'font-size: $ 2 px '> $ 3 </ span> ");

/ / Color ...
code = code.replaceAll ("(\ \ [color =(.*?) \ \ ])(.*?)( \ \ [\ \ / color \ \])", "<span'color: $ 2; ' > $ 3 </ span> ");

/ / Image [img code = pic/1.jpg]
code = code.replaceAll ("(\ \ [img code =(.*?) \ \])", "<img src='$2' />");

return code;
}

public static void main (String [] args) {
System.out.println (filter ("[img code = pic/1.jpg] [img code = pic/10.jpg ]"));
}

}

相关文章
  • Web page conversion of special characters, such as [image] 2011-01-02

    package com.email.util; public class BBCODE { / / / / [Img code = "1.jpg"] [img code = "2.jpg"] / / <img Src="1.jpg" /> <img src="2.jpg" /> public static String filter (String code) { / / Bold ... code =

  • HTML.JS.JSON special characters 2010-12-13

    JS to convert HTML special characters These days to do the project, found that in JSON format from the server to pass data to the client, by JS displayed in HTML pages, there are some special characters can not be directly displayed as the background

  • special characters in web development 2011-07-17

    Special characters in URL Special characters in the URL is the URL can not be passed directly to the need for coding. Encoding format:% plus ASCII character code, that is, a percent sign% followed by the corresponding characters of ASCII (16 hex) cod

  • Escape special characters 2010-06-13

    Transfer from (http://xhfei.javaeye.com/admin/blogs/new) # Spring not only provides a full-featured application development framework, itself also has a number of programming when you can use the tools directly, you can not only apply in the Spring c

  • SQL on the basic method of handling special characters 2010-07-13

    Must be entered on the user, such as quotes, angle brackets and other special characters to give adequate attention, they may cause serious security problems. SQL injection is one of the basic approach is to use single quotation marks unfiltered secu

  • URL handling of special characters 2010-09-23

    Transfer from http://www.jb51.net/article/21691.htm Hex value 1. + URL in the space% 2B + sign indicates 2. URL spaces in space can be numbers or codes% 20 + 3. / Separate directory and subdirectories% 2F 4.? Separated the actual URL and the paramete

  • HTML special characters display 2010-11-12

    HTML character entities (Character Entities) Some characters have special meaning in HTML, such as less-than <HTML Tag to the start of that, this is not less than the number displayed on our website to see where the final. What if we want to display

  • JSP and interactive data and special characters JavaScirpt handling 2010-12-13

    Data exchange data and JavaScirpt JSP JSP data and JavaScirpt the use of a data exchange solution for the WEB program, the front-end (JavaScript) and back-end (JSP / Servlet) is no way to share data, only the back-end program (JSP) to data output To

  • RAQ show the flexibility of handling special characters 2011-05-05

    In web applications, often encountered in the treatment of some special characters, such as to display such characters "" in Html, word, and java in a separate character in this show is very simple. But when the three conditions required in this

  • SEO Learning: Web page search engine optimization and keyword positioning guide 2011-06-18

    How can we make a full compliance with search engine optimization a standard page? If you're doing search engine optimization, you may have heard many times the above questions. Unfortunately, ah, there is no one size fits all and very definite answe

  • Web page performance optimization Summary 2010-03-20

    Web page performance optimization First, add Expire / Cache-Control header: Add an Expires Header Now, more and more pictures, scripts, css, flash is embedded to the page, when we visit when they do many times is bound to http requests. In fact, we c

  • Replace special characters java 2010-04-14

    Today in the jsp page in js calendar display with a special character string, the string end of the reporting error, use replaceAll ("\ \ s +", "") can replace the special characters, replacing the previous statement spaces, and can al

  • Flex and Java types types of instructions and embedded web page 2010-04-15

    Flex embedded web page <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:flexiframe="http://code.google.com/p/flex-iframe/"> <flexiframe:IFrame label="Google" source="http://www.google.com" wi

  • Web page speed optimization 2010-05-13

    1, optimal image Almost no page is no images. 56K cat if you have experienced the era, you will not like a lot of pictures of the site. Because as a web page will load a lot of time. Even now, a lot of network bandwidth has increased, 56K cat faded,

  • java url in dealing with special characters 2010-05-13

    java url in dealing with special characters (such as &,%...) URL (Uniform Resoure Locator, Uniform Resource Locator) is the Internet in a unified resource location and management of the signs. A complete URL, including the following: 1. Application p

  • HTTP requests pass special characters 2010-06-22

    1, how to accept http request pass the special characters. First of all, must be converted to special characters, use URLEncoder.encode ("EKIDAO / SDE% KD @ f + ^", "UTF-8"). For example: http://localhost:8088/uc/LoginAction.do?method=

  • From the UE (user experience) point of attention to detail in web page design 2010-06-29

    The quality of a website design is directly related to search engine friendliness and user experience process, this article introduces the Web design from the UE (user experience) point of view of six details. 1, reduce the page loading time: the vas

  • How to make web page Flash video player in the pop-up window 2010-06-29

    Many browsers have this feature, when you move the mouse to the video on the web page, you can see there is a button appears at the top, pop-up an independent player. When you click the button, the video playback in a new window will pop up, and this

  • [Change] web page, and Simhash of weight algorithm Shingling 2010-07-08

    1 Introduction According to statistics, the duplication of pages on the Internet about 30% to 45%. This image is reproduced which caused because the pages are identical, there are only minor differences existing pages, such as advertising, counters,

  • 20 kinds of techniques to enhance the speed of web page 2010-08-03

    Introduction Not everyone is able to use high-speed Internet connection. Even if everyone can use high-speed network, will be for a variety of reasons to look for your Web application to run slowly. In this era of increasing broadband speeds, you sho