Java uses regular expressions to convert UBB IMG expression methods to HTML style

xiaoxiao2021-03-06  43

Import java.util.regex. *;

/ / This method is used to resolve the use of the UBB's IMG expression method to HTML style, use the REGX package

Public Static String ConvertTags (String Str)

{

IF (str == null || str.length () == 0)

{

Return Str;

}

String Patt = "

// [img //]) ([^ // [] ) (// [/ IMG //]) ";

Pattern P = Pattern.Compile (Patt);

Matcher M = P.matcher (STR);

StringBuffer SB = new stringbuffer ();

INT i = 0;

Boolean Result = m.find ();

While (result)

{

i ;

M.AppendReplacement (SB, "");

Result = m.find ();

}

M.AppendTail (SB);

Return sb.toString ();

}

转载请注明原文地址:https://www.9cbs.com/read-113778.html

New Post(0)