14.3. Regular expressions-syntax

发布时间 :2025-10-25 12:24:08 UTC      

Regular expression (regular expression) describes a string matching pattern (pattern), which can be used to check whether a string contains a certain substring, replace a matching substring, or extract a substring from a string that meets a certain condition.

For example:

  • Runoo+b, can match runoob、runooob、runoooooob The + sign indicates that the preceding character must appear at least once (1 or more times).

  • Runoo b,可以匹配 * *runob、runoob、runoooooob * 等,* The number indicates that the preceding character may not appear, or it can occur one or more times (0, or 1, or more).

  • Colou?r can match. color Or colour ,? The question mark indicates that the preceding character can appear at most once (0 or 1 time).

You construct regular expressions in the same way as you create mathematical expressions. That is, you can combine small expressions with multiple metacharacters and operators to create larger expressions. The components of a regular expression can be a single character, a character collection, a character range, a choice between characters, or any combination of all these components.

A regular expression is a text pattern that consists of ordinary characters (such as characters a to z) and special characters (called metacharacters). The pattern describes one or more strings to match when searching for text. The regular expression acts as a template that matches a character pattern with the searched string.

14.3.1. Ordinary character

Normal characters include all printable and non-printable characters that are not explicitly specified as metacharacters. This includes all uppercase and lowercase letters, all numbers, all punctuation, and some other symbols.

Character

Description

Example

[ABC]

Match [...] All characters in, such as [aeiou] Matches all e o u a letters in the string “google runoob taobao”.

image0

尝试一下

[^ABC]

Except for Standard PvP match [...] All characters in the, such as [^aeiou] Matches all characters in the string “google runoob taobao” except the e o u a letter.

image1

尝试一下

/media/sphinx_tuto/img/E691DDE1-E5CB-4EA8-8D16-759BD0D2B09D1.jpg/media/sphinx_tuto/img/ED971D92-30F4-4768-A2C7-02A84A3A9DEB1.jpg

Principles, Technologies, and Methods of Geographic Information Systems  102

In recent years, Geographic Information Systems (GIS) have undergone rapid development in both theoretical and practical dimensions. GIS has been widely applied for modeling and decision-making support across various fields such as urban management, regional planning, and environmental remediation, establishing geographic information as a vital component of the information era. The introduction of the “Digital Earth” concept has further accelerated the advancement of GIS, which serves as its technical foundation. Concurrently, scholars have been dedicated to theoretical research in areas like spatial cognition, spatial data uncertainty, and the formalization of spatial relationships. This reflects the dual nature of GIS as both an applied technology and an academic discipline, with the two aspects forming a mutually reinforcing cycle of progress.