Replace special characters in the report name with regular expressions (recommended) and special characters in Regular Expressions
A regular expression, also known as a rule expression. (English: Regular Expression, often abbreviated as regex, regexp or RE in code), a concept of computer science. Regular tables are usually used to retrieve and replace texts that conform to a certain pattern (rule.
Many programming languages Support string operations using regular expressions. For example, a powerful Regular Expression Engine is built in Perl, And the built-in java language is also used. The concept of regular expressions was initially popularized by tools in Unix (such as sed and grep. Regular Expressions are abbreviated as "regex". The singular values include regexp and regex, And the plural values include regexps, regexes, and regexen.
// Expression object Pattern p = Pattern. compile ("[\\\\? \ * \: \ [\] \/] "); // Create a Matcher object Matcher n = p. matcher (systemName); Matcher m = p. matcher (unitCodeName); // replace String sheetNameSystem = n. replaceAll (""); String sheetNameUnit = m. replaceAll ("");
The following describes how to replace all special characters with Java regular expressions.
The Java Regular Expression replaces all special characters as follows:
/*** Replace all special characters with regular expressions * @ param orgStr * @ return */public static String replaceSpecStr (String orgStr) {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 section describes how to use regular expressions to replace special characters in the report name to simulate background data login, if you have any questions, please leave a message and the editor will reply to you in time. Thank you very much for your support for the help House website!