Get started with RegEx! (For failing programmers) page 1/4

Source: Internet
Author: User

Regular Expression
This section compares with some concepts that most readers are already familiar with to describe the concept of regular expressions.

This article is all about Microsoft documents.
I would like to express my gratitude to those who have worked for this.

You may not be familiar with this term unless you have used regular expressions before. However, you have undoubtedly used some regular expressions that do not involve scripts.

For example, you are likely to use? And * wildcard to find the files on the hard disk .? Wildcard matches a single character in the file name, while * wildcard matches zero or multiple characters. Like data ?. In dat mode, you can find the following files:

Data1.dat
Data2.dat
Datax. dat
DataN. dat
Use * characters instead? The characters increase the number of files found. Data *. dat matches all 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 the concept that regular expressions depend on, but regular expressions are more powerful and flexible.
Usage of Regular Expressions
Use an instance to explain how regular expressions can expand regular search conditions.

Typical search and replacement operations require you to provide the exact text that matches the expected search results. Although this technology may be sufficient for simple search and replacement tasks on static text, it lacks flexibility. If dynamic text is searched using this method, even if it is not impossible, at least it will become very difficult.

By using a regular expression, you can:

Test the mode in the string.
For example, you can test the input string to check whether the phone number mode or credit card number mode is displayed in the string. This is called data verification.

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

Extract substrings from strings based on pattern matching.
You can search for specific texts in a document or input domain.

For example, you may need to search the entire Web site, delete outdated materials, and replace some HTML format tags. In this case, you can use a regular expression to determine whether the material or HTML format tag appears in each file. This process reduces the list of affected files to the files containing the materials to be deleted or changed. Then, you can use a regular expression to delete outdated materials. Finally, you can use a regular expression to search for and replace tags.

Regular Expressions are also useful in languages such as JScript and C, and the character string processing capabilities of these languages are unknown.

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.