El contenido no se encuentra disponible en el idioma seleccionado. Estamos trabajando continuamente para agregar más idiomas. Gracias por su apoyo.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
Software Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
On this page

Show all

Help Center/ CodeArts PerfTest/ User Guide/ Reference/ Regular Expression Metacharacters

Regular Expression Metacharacters

Updated on 2023-07-13 GMT+08:00
Table 1 Metacharacter description

Metacharacter

Description

.

Matches any characters except \n. If \n needs to be included, use other modes such as [\s\S].

^

Matches the start position of an input character string and does not match any characters. Use \^ to match the character itself.

$

Matches the end position of an input character string and does not match any characters. Use \$ to match the character itself.

*

The preceding characters or sub-expressions are matched zero or more times. * is equivalent to {0,}. For example, \^*b can match b, ^b, ^^b, and so on.

+

Matches preceding characters or sub-expressions one or more times, equivalent to {1}. For example, a+b can match ab, aab, abb, aaab, and so on.

?

Matches preceding characters or sub-expression zero times or once, equivalent to {0,1}. For example, a[cd]? can match a, ac, and ad. When this character follows any other qualifier such as *, +, ?, {n}, {n,}, or {n,m}, the matching mode is non-greedy. Non-greedy mode matches the shortest possible searched character strings, and the default greedy mode matches the longest possible searched character strings. For example, the character string oooo, o+? matches only a single o, while o+ matches all o.

|

The logic or is performed on two matching conditions. For example, the regular expression (him|her) matches it belongs to him and it belongs to her, but cannot match it belongs to them.

\

Marks the next character as a special character, text, reverse reference, or octal escape character. For example, n matches the character n, \n matches the newline character, \\ matches \, and \( matches (.

\w

Matches a letter, digit, or underscore (_).

\W

Matches any character that is not a letter, digit, or underscore (_).

\s

Matches any blank character, such as a space, tab character, or form feed. It is equivalent to [ \f\n\r\t\v].

\S

Matches any character except blank characters and is equivalent to [^\f\n\r\t\v].

\d

Matches any digit and is equivalent to [0–9].

\D

Matches any non-digital character and is equivalent to [^0-9].

\b

Matches a word boundary (the position between a word and a space) and does not match any characters. For example, er\b matches er in never but does not match er in verb.

\B

A non-word boundary match. For example, er\B matches er in verb but does not match er in never.

\f

Matches a form feed and is equivalent to \x0c and \cL.

\n

Matches a linefeed and is equivalent to \x0a and \cJ.

\r

Matches a carriage return character and is equivalent to \x0d and \cM.

\t

Matches a tab character and is equivalent to \x09 and \cI.

\v

Matches a vertical tab character and is equivalent to \x0b and \cK.

\cx

Matches control characters indicated by x. For example, if \cM matches Control-M or a carriage return character, the value of x must be between A–Z or a–z. Otherwise, the c character indicates c itself.

{n}

The value n is a non-negative integer and refers to the number of matching times. For example, o{2} does not match o in Bob, but matches o in food.

{n,}

The value n is a non-negative integer and refers to the minimum number of matching times. For example, o{2,} does not match o in Bob but matches all o in foooood. o{1,} is equivalent to o+, and o{0,} is equivalent to o*.

{n,m}

The values n and m (n≤m) are non-negative integers, where n refers to the minimum number of matching times and m refers to the maximum matching times. For example, o{1,3} matches the first three os in fooooood, and o{0,1} is equivalent to o?. Note that a space cannot be inserted between commas and digits. For example, ba{1,3} can match ba, baa, or baaa.

x|y

Matches x or y. For example, z|food matches z or food, and (z|f)ood matches zood or food.

[xyz]

Refers to a character set that matches any characters included. For example, [abc] matches a in plain.

[^xyz]

Refers to a reverse character set that matches any characters except xyz. For example, [^abc] matches p in plain.

[a-z]

Refers to a character range and matches any characters in the specified range. For example, [a-z] matches any lowercase letters from a to z.

[^a-z]

Refers to a reverse character range and matches any characters not in the specified range. For example, [^a-z] does not match any characters from a to z.

( )

Defines expressions between ( and ) as group and save characters that match the expression to a temporary area. A maximum of nine characters can be saved in a regular expression, and these characters can be referenced by symbols \1 to \9.

(pattern)

Matches pattern and captures sub-expressions of the match. You can use the $0–$9 attribute to retrieve captured matches from the result match set.

(?:pattern)

Matches pattern but does not capture sub-expressions of the match. That is, it is a non-capture match and does not store matches for future use. This is useful for the or character combined with (|). For example, industr(?:y|ies) is a simpler expression than industry|industries.

(?=pattern)

Refers to a non-capture match and indicates a forward positive pre-check, searching character strings at the start position of any character strings that match pattern. There is no need to capture the match for future use. For example, "Windows(?=95|98|NT|2000)" matches "Windows" in "Windows2000", but does not match "Windows" in "Windows3.1". A pre-check does not consume characters. That is, after a match occurs, the next search starts immediately, instead of starting from pre-checked characters.

(?!pattern)

Refers to a non-capture match and indicates a forward negative pre-check, searching character strings at the start position of any character strings that do not match pattern. There is no need to capture the match for future use. For example, "Windows(?=95|98|NT|2000)" matches "Windows" in "Windows3.1", but does not match "Windows" in "Windows2000".

NOTE:

To match special characters, add \ before the special characters. For example, to match the following special characters: ^, $, (), [], {}, ., ?, +, *, and |, use \^, \$, \ (, \), \ [, \], \{, \}, \., \?, \+, \*, and \|.

Utilizamos cookies para mejorar nuestro sitio y tu experiencia. Al continuar navegando en nuestro sitio, tú aceptas nuestra política de cookies. Descubre más

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback