14.3. Regular expressions-syntax

发布时间 : 2025-10-25 13:33:21 UTC      

Page Views: 9 views

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
《地理信息系统原理、技术与方法》  97

最近几年来,地理信息系统无论是在理论上还是应用上都处在一个飞速发展的阶段。 GIS被应用于多个领域的建模和决策支持,如城市管理、区划、环境整治等等,地理信息成为信息时代重要的组成部分之一; “数字地球”概念的提出,更进一步推动了作为其技术支撑的GIS的发展。 与此同时,一些学者致力于相关的理论研究,如空间感知、空间数据误差、空间关系的形式化等等。 这恰好说明了地理信息系统作为应用技术和学科的两个方面,并且这两个方面构成了相互促进的发展过程。