This blog stops updating, the new home address http://ashun.cnblogs.com/
Regular Expression Use Detailed Detailed (2) After using an instance after a comprehensive understanding of the regular expression, let's take a look at how to use the regular expression in Perl, PHP, and JavaScript. Typically, the usage format of regular expressions in Perl is as follows: Operator / regular-expression / string-to-replace / modifiers operator one can be M or S, represent matching operations and replacement operations, respectively. Among them, the regular expression is a mode that will match or replace the operation, can be composed of any character, element character, or locator. The replacement string is a string that matches the object to the object when the search mode matchs the object. The final parameter item is used to control different match or replacement. For example: S / Geed / Good / will look for the first GEED string in the target object and replace it with a good. If we want to perform multiple lookups-replacement operations in the global scope of the target object, you can use the parameter "g", which is S / Love / Lust / G. In addition, if we don't need to limit the case where you don't need to limit the matching form, you can use the parameter "I". For example, M / Jewel / i The above regular expression will match Jewel, Jewel, or Jewel in the target object. In Perl, use specialized operators "= ~" to specify matching objects of regular expressions. For example: $ FLAG = ~ S / ABC / ABC / The above regular expression will replace the string ABC in the Variable $ FLAG to ABC. Below, we add regular expressions in the Perl program to verify the validity of the user's mail address format. The code is as follows: #! / Usr / bin / perl # GET INPUT Print "What's your email address" / n "; $ EMAIL =