Today, there is another problem with promote baseline, and Paul made some changes.
Regular Expression eight principles: (http://www.aka.org.cn/Lectures/002/Lecture-2.1.2/perl-reg.html)
· Principle 1: regular expressions have three different forms (matching (M //), replacement (S // EG), and conversion (TR ///)).
· Principle 2: Regular Expressions only match scalar values ($ scalar = ~ M/A/; can work; @ array = ~ M/A/will treat @ array as a scalar, so it may not succeed ).
· Principle 3: Regular Expressions match the earliest possible match of a given pattern. Lack of time, only match or replace the regular expression once ($ A = 'string string2'; $ A = ~ S/string //; causes $ A = 'string 2 ').
· Principle 4: Regular Expressions can process any and all characters that double quotation marks can process ($ A = ~ M/$ varb/extend varb to a variable before matching. If $ varb = 'A' $ A = 'as', $ A = ~ S/$ varb //; equivalent to $ A = ~ S/A //;, the execution result is $ A = "S ").
· Principle 5: the regular expression produces two situations in the value evaluation process: Result Status and reverse reference: $ A = ~ M/pattern/indicates whether the child string pattern appears in $ A, $ A = ~ S/(word1) (word2)/$2 $1/the word "change.
· Principle 6: the Core Competence of Regular Expressions lies in wildcards and Multiple matching operators and how they operate. $ A = ~ M/\ W +/matches one or more word characters; $ A = ~ M/\ D/"matches zero or multiple numbers.
· Principle 7: To match more than one character set, Perl uses "|" to increase flexibility. If M/(cat | dog)/is input, it is equivalent to "matching string cat or dog.
· Principle 8: Perl (?..) The Syntax provides extended functions for regular expressions.
Question 1:
From "m_x75plat_mp-Main_1.0_v118: Project: mc75p #1 ", extract" _ 1.0 _ v118 "and splice it into" cmt_x75plat_1.0_v118_060221"
Or from "m_x75plat_mp-MEC # main_1.0_v15.1: Project: mc75p #1 ", extract" _ 1.0 _ v15.1 "and splice it into" cmt_x75plat_1.0_v15.1_060221"
If ($ version = ~ /#/){
($ Baseline = $ version) = ~ S/^ (. *) \ # (. *) \ s * $ */CMT _ $2 _ $ date /;
} Else {
$ Baseline = "CMT _". $ version. "_". $ date;
}
$ Baseline = $ out;
Chomp $ baseline;
$ Out = ~ S/^ (. *) \-(. *) \ :(. *) \ :(. *) \ s */$2 /;
If ($ out = ~ /#/){
$ Baseline = ~ S/^ (. *) \-([^-] +) \ # (. *) \ :(. *) \ :(. *) \ s */$3 /;
} Else {
$ Baseline = ~ S/^ (. *) \-(. *) \ :(. *) \ :(. *) \ s * $*/$2 /;
}
$1, $2. These variables correspond to the preceding ones, and do not need to be replaced with the characters (. *).
For example
$ String = "a B C D E F G ";
$ String = ~ S/(A) (. *) (c d e) (. *)/$2 $4 /;
Print $ string;
Now the running result is
B f g