What is a formal representation, which is for the file, string, through a very special representation, Search and Replace, because there are many system settings on UNIX, are stored in text files, so network management or program design It is often necessary to search and replace, so developing a special command called a formal representation we can simply use the "S / LT; / G" regularly convert all the "<" of the "<" in the string into the strings. "LT;" Therefore, JDK1.4 provides a set of formal representative packages for your use of JDK1.4 or less than Http://jakarta.apache.org/oro gets a string of Package. The symbol "S / LT; / G" is a formal syntax, so please understand the formal representation of J2SDK1.4 "." Represents the string of the normal syntax of J2SDK1.4. AB A .. ABC AB " " represents one or more characters "*" represents zero or more characters formal primr-based primary primordinal skewers in accordance with the string ab * abc ABC "" group Group regular primary skewers in line (ab) * Aabab abab character class formal primary primitive string compliant string [A-DA-D0-9] * abcza0 abca0 [^ ad] * ABE0 E0 [ad] * Abcdefgh abab Simply / D is equal to [0-9] Number / D is equal to [^ 0-9] non-numeric / s equal to [/ T / N / X0B / F / R] blank font / s equal to [^ / T / N / X0B / F / R] Non-blank character / w equal to [A-ZA-Z_0-9] number or English word / W is equal to [^ a-za-z_0-9] non-numbers and English words every line The beginning or end ^ indicates that the beginning of each line is the end of each line ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------- Regular representation Java .util.Regex Related Categories Pattern-Regular Representation Matcher - Formalized Results PatternsyntaxExpression-Exception Thrown While Attempting To Compile A Regular Expression Example 1: Replace all the characters in the strings in line with "<" "" import java.io. *; IMPO Rt java.util.regex. *; / *** Replace all the characters in the strings in line with "<" into "LT;" * / public static void replace01 () {// bufferedreader lets us read line-by- LineReader R = New InputStreamReader (System.IN); BufferedReader Br = New BufferedReader (R); Pattern Pattern = Pattern.Compile ("<"); // Search for a string all the '<' character Try {while ( True) {string line = br.readline (); // null line means input is exhaustedif (line == null) Break; matcher a = pattern.matcher (line); while (a.find ()) {system.out .println ("Searching by" A.Group ());} system.out.println (A.ReplaceAll ("LT;")); // Replace all character in line with the character.