1. Three forms of regular expressions first we should know that in the Perl program, there are three forms of presence, they are: Match: m /
/ pattern / result. Match all character x? Match 0 times or once X * matches 0 times or multiple times, but match the minimum number of X match 1 or more X characters String, but match the least least. * Match 0 or once any character. Match 1 or more characters {m} matches just M, specified strings {m, n} matches M, The specified string of the above nies is {m,} matches M or more specified strings [] matching characters in [] matching characters in [] matching characters in [0-9] match all numeric characters [ AZ] Match all lowercase letters characters [^ 0-9] Match all non-digital characters [^ AZ] match all non-written alphanumeric characters ^ Match the character of the character $ Match the character / d Matched a number characters, and [ 0-9] Syntax, same / d match multiple numeric strings, and [0-9] syntax, the same / D non-digital, other same / d / d non-digital, other same / d / w English letters or characters String, and [A-ZA-Z0-9] syntax, same / w and [A-ZA-Z0-9] syntax, same / W non-English letters or numbers, and [^ A-ZA-Z0-9 ] Syntax is the same / w and [^ a-za-z0-9] syntax, same / s space, and [/ n / t / r / f] syntax like / s and [/ n / t / r / f] The same / s non-space, and the [^ / N / T / R / F] syntax like / s and [^ / n / t / r / f] syntax same / b match the character string of English letters, numbers as boundary / B matches the string A | B | C matching the A-character string ABC matches the ABC, which matches the ABC, which matches the ABC, or the C character, or a string ABC that matches the A character or the C character. It is a very practical syntax for a string to stay. The first () found string becomes a $ 1 variable or / 1 variable, the string found in the second () becomes a $ 2 variable or / 2 variable, and it is pushed. / Pattern / I i This parameter indicates that ignore English big lowercase, that is, when matching strings, do not consider the case of English. / If you want to find a special character in Pattern mode, if you want to add / symbol before this character, you will make special characters fail to fail 3, the eight principles of regular expressions If you have used in Unix If these commands, this command, I believe it is not strange to regular expression (Regular Expression). Here are 8 principles from several regular expressions during use. Regular expressions can form a huge alliance in combat against data - this is often a war. We must remember the following eight principles: • Principle 1: Regular expression has three different forms (match (m / / /), replacement (S / / / EG) and conversion (TR / / /)). · Principle 2: Regular expression only matches the scalar ($ scalar = ~ m / A /; can work; @Array = ~ m / A / will treat @Array as scales, so it may not succeed). · Principle 3: Regular expression matches the earliest possible match of a given mode. By default, only regular expressions are matched or replaced ($ A = 'string string2'; $ a = ~ s / string / /; resulting in $ A = 'string 2').