Removes the matching string from the string.
CopyCode The Code is as follows :/**
* Remove the matched strings from the string.
*
* @ Author zhujie
* @ Return string RegEx content to be replaced what is the content replaced by value string state?
*/
Public static string toregex (string RegEx, string value, string state ){
Pattern P = pattern. Compile (RegEx );
Matcher M = P. matcher (value );
Stringbuffer sb = new stringbuffer ();
While (M. Find ()){
M. appendreplacement (SB, State );
}
M. appendtail (SB );
Return sb. tostring ();
}
Copy codeThe Code is as follows: public static void main (string [] ARGs ){
* String RegEx = "\ P {lower}"; // remove the lower-case character RegEx = "'"; // remove'
* RegEx = "\ P {SC}"; // remove the currency symbol $ RegEx = "\ P {punct}"; // remove all the symbols in it
* RegEx = "\" "; // remove" RegEx = "<.>"; // remove the HTML Tag
*
* String value = "fjdks <SSS> jfl 'fdk $ jfl ";
* System. Out. println (toregex (RegEx, value ,""));
*/
}