Regular introduction to the serial! (to a failed program) 1th/4 page _ Regular expression

Source: Internet
Author: User
Regular Expressions
The concept of regular expressions is illustrated by comparing some concepts that are already familiar to most readers.

The content of this article is all Microsoft company documentation
Thank you for this, like those who have worked for it.

You may not be familiar with this term unless you have used a regular expression before. However, there is no doubt that you have used some regular expression concepts that do not involve scripting.

For example, are you likely to use? and * wildcard characters to find the files on your hard disk. Wildcard characters match a single character in the file name, while the * wildcard matches 0 or more characters. Like data? DAT mode will look for the following files:

Data1.dat
Data2.dat
Datax.dat
DataN.dat
Use the * character instead? The character expands the number of files found. Data*.dat matches all of the following files:

Data.dat
Data1.dat
Data2.dat
Data12.dat
Datax.da
DataXYZ.dat
Although this search method is useful, it is still limited. and * wildcard capabilities introduce concepts that regular expressions rely on, but regular expressions are more powerful and more flexible.
use of regular expressions
Illustrates how regular expressions extend general search conditions through an instance.

A typical search and replace operation requires that you provide exact text that matches the expected search results. While this technique may suffice for performing simple search and replace tasks on static text, it lacks flexibility, and it can be difficult, if not impossible, to search for dynamic text in this way.

By using regular expressions, you can:

Tests the pattern within the string.
For example, you can test the input string to see if phone number mode or credit card number mode appears within the string. This is called data validation.

Replaces text.
You can use regular expressions to identify specific text in a document, to completely delete the text, or to replace it with other text.

Extracts a substring from a string based on pattern matching.
You can find specific text within a document or in an input field.

For example, you might want to search the entire Web site, remove obsolete materials, and replace some HTML formatting tags. In this case, you can use a regular expression to determine whether the material or the HTML formatting tag appears in each file. This procedure shrinks the list of affected files to those that contain materials that need to be deleted or changed. You can then use regular expressions to delete obsolete materials. Finally, you can use regular expressions to search for and replace tags.

Regular expressions are also useful in languages such as JScript or C, and the string-handling power of these languages is not yet known.
Current 1/4 page 1234 Next read the full text

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.