14.4. Regular expression-modifier (tag)

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

Tags are also called modifiers, and the tags of regular expressions are used to specify additional matching strategies.

The tag is not written in the regular expression, but outside the expression in the following format:

/pattern/flags

The following table lists the modifiers commonly used in regular expressions:

Modifier

Meaning

Description

I

Ignore-case insensitive

Set the match to case-insensitive and search case-insensitive: there is no difference between An and a.

G

Global-Global matching

Find all matches.

M

Multi line-multiline matching

Make the boundary character? ^? And? $? Match the beginning and end of each line, keeping in mind that it is multiple lines, not the beginning and end of the entire string.

S

特殊字符圆点?.?中包含换行符?n

Dots by default?? Is it a match divided by newline characters?n? Any character other than, plus? s? After the modifier,? Contains a newline charactern.

14.4.1. G modifier

The g modifier finds all matches in the string:

image0

14.4.2. Example

Look for “runoob” in the string:

varstr="Google runoob taobao
runoob";varn1=str.match(/runoob/);//查找第一次匹配项varn2=str.match(/runoob/g);//查找所有匹配项

尝试一下 »

14.4.3. I modifier

The I modifier is case-insensitive. An example is as follows:

image1

14.4.4. Example

Look for “runoob” in the string:

varstr="Google runoob taobao
RUNoob";varn1=str.match(/runoob/g);//区分大小写varn2=str.match(/runoob/gi);//不区分大小写

尝试一下 »

14.4.5. M modifier

The m modifier makes ^ and $match the beginning and end of each line in a paragraph of text.

G matches only the first line, and multiple lines are implemented after adding m.

image2

Line wrapping is used in the following instance string:

14.4.6. Example

Look for “runoob” in the string:

varstr="runoobgoogle\\ntaobao\\nrunoobweibo";varn1=str.match(/^runoob/g);//匹配一个varn2=str.match(/^runoob/gm);//多行匹配

尝试一下 »

14.4.7. S modifier

默认情况下的圆点 . 是 匹配除换行符 \n 之外的任何字符,加上 s 之后, . 中包含换行符 \n。

image3

An example of the s modifier is as follows:

14.4.8. Example

Look in the string:

varstr="google\\nrunoob\\ntaobao";varn1=str.match(/google./);//没有使用
s,无法匹配\nvarn2=str.match(/runoob./s);//使用 s,匹配\n

尝试一下 »

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.