Regular expressions, also known as regular expressions. (English: Regular Expression, often abbreviated as regex, RegExp, or re) in code, a concept of computer science. Regular tables are often used to retrieve and replace text that conforms to a pattern (rule).
Many programming languages support the use of regular expressions for string manipulation. In Perl, for example, a powerful regular expression engine was built, as well as the Java language itself. The concept of regular expressions was initially popularized by tool software (such as SED and grep) in Unix. Regular expressions are usually abbreviated as "regex", singular with regexp, regex, plural with regexps, regexes, Regexen.
Expression object Pattern
p = Compile ("[\\\\?\\*\\:\\[\\]\\/]");
Create Matcher object
Matcher n = p.matcher (systemname);
Matcher m = P.matcher (unitcodename);
Replace
String Sheetnamesystem = N.replaceall ("");
String sheetnameunit = M.replaceall ("");
Look at the following Java regular expressions replace all special characters
The Java regular expression replaces all special characters as follows:
/**
* Replace all special characters
* @param orgstr
* @return/Public
static string Replacespecstr (String orgstr) { C6/>if (null!=orgstr&&! "". Equals (Orgstr.trim ())) {
String regex= ' [\\s~ '!! @#¥$%^......&* (()) \ \-—— \\-_=+ "\\[\\]" {{}}\\|, \\\\;;:: "" "\", "<." >,/??] ";
Pattern p = pattern.compile (regEx);
Matcher m = P.matcher (ORGSTR);
Return M.replaceall ("");
}
return null;
The above is a small set for you to introduce the use of regular expressions to replace the special characters in the report name, to achieve a simulated background data login effect, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!