Regular expressions that match any character, including both English and any punctuation
Regex: \\w*|\\w*| [\\u4e00-\\u9fa5] This expression matches an arbitrary Chinese-English character.Where: \w:a word character: [a-za-z_0-9] (matches a word character); Where: \w:a non-word character: [^\w] (match a non-word character); Where: [\\u4e00-\\u9fa5]: Match a Chinese character;
ref:http://saltdstar.iteye.com/blog/1041690
Ref:http://www.jb51.net/article/19713.htm
ref:http://www.jb51.net/article/64301.htm Test Cases:
Package cn.mike.march;
public class Matchesallcharactersincludechinese {public
static void Main (string[] args) {
String Singlewordregex = "\\w*|\\w*| [\\u4e00-\\u9fa5] ";
String chinesecharacter = "Ben";
System.out.println ("1_:" + chinesecharacter.matches (Singlewordregex));
String Multiplewordsregex = "(\\w*|\\w*|[ \\u4e00-\\u9fa5]*) * ";
String examplecharacters = "My days as Shine df134 Shine wsdf64?><?>|_!@@. :;... #$%%^&* (Ah ... ";
System.out.println ("2_:" + examplecharacters.matches (Multiplewordsregex));
String regex = "^[a-z]{1}" (\\w*|\\w*|[ \\u4e00-\\u9fa5]*) *[. ]{1}$ ";
String ExampleChars3 = "B my god asdf13464?><?>|_!@@#$%%^&* (ah. ";
System.out.println ("3_:" + examplechars3.matches (regex));
}
}
/** Output:
1_: True
2_: True
3_: true
*/
Appendix:Regular expression matching Chinese characters: [\u4e00-\u9fa5] matches double-byte characters (including kanji): [^\x00-\xff] In a text file, this expression can match all English:/[-~]/This expression can match all non-English (such as Chinese):/[^- ~]/
Note: There is a space in the middle of the expression;
The Regular expression tool:JavaScript Regular expression Online test tool: http://tools.jb51.net/regex/javascript Regular expression online generation tool: Http://tools.jb51.net/regex/create_reg
by Mike Sun @ 20170330