The use of regular expressions in network programming
Hot Recommended Microsoft New Technology ASP.NET Full Getting Started [Foreword:] When we write a web program, the validity of a string often judges, such as whether a string is a number, whether it is a valid Email address, etc. If you do not use a regular expression, the program that judges will be very long, and it is easy to make mistakes. If you use the regular expression, these judgments are a very easy task. This article fully introduces the regular expressions, format. And add readers' sensibility understanding in PHP, ASP. Regular expressions are widely used, and you need to summarize in learning and practice. Publish your opinion to write a letter to Microsoft.NET Summary Visual Basic Database Developing Battle Record Visual Basic Network App Instance Collection Regular Expression Introduction Simple, Regular Expression is a strong to mode match and replacement Powerful tools. Applications in network programming, such as PHP scripting languages or JavaScript, client scripts such as VBScript provide support for regular expressions. It can be seen that the regular expression has exceeded the limitations of some languages or a system, and has become a widely accepted concept and function. Regular expression allows users to build a matching mode by using a series of special characters, then compare the matching mode with data files, program input, and web pages, whether or not to include matching mode in the comparison object, perform corresponding program of. For example, a general expression of a regular expression is to verify that the format of the mail address input by the user online is correct. If the format of the user's mail address is verified by the regular expression, the form information filled in the user will be Normally; Conversely, if the user entered by the mail address does not match the pattern of regular expression, the prompt information will be popped up, requiring the user to re-enter the correct email address. This shows that the regular expression has a pivotable role in the logical judgment of the web application. Behind we will give an example detail. Regular expressions are generally as: / love /, where the "/" part of the "/" The segment is the mode to match in the target object. Users can put them between the mode content you want to find the matching object in the "/" delimiter. In order to be able to make user more flexible custom mode content, regular expressions provide special "metadamic characters". The so-called metammatism refers to the exhibit mode of its preamble characters (i.e., characters in front of the metamorphism) in the regular expression. More commonly used metamodes include: " ," *, μ, and {} ", or" / s, / s, / d, / w, and / w ", etc. In order to facilitate user more flexible setting matching mode Regular expression allows the user to use [] to define a character in a matching mode without being limited to a specific character. In addition to our metammatism, the regular expression also has another unique Special characters, ie, locator. Locator is used to specify the appearance position of the matching mode in the target object. More commonly used locators include: "^", "$", "/ b", "/ b". If we It is desirable to implement "or" or "operations in the regular expression. If you choose to match in multiple different modes, you can use the duct" | ". For example: there is a general purpose in the regular expression. The operator, ie, negative "[^].". Different from the positioning character "^" mentioned above, the negative "[^]" specifies the string specified in the mode in the mode in the target object.