The study record of Regular Expression 正则表达式学习笔记

本文详细介绍了正则表达式的概念、组成、元字符、特殊符号等核心内容,通过实例展示了如何使用正则表达式进行文本搜索、匹配、解析等操作,旨在帮助读者掌握正则表达式的强大功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Regular expressions are the key to powerful, exible, and efŒcient text processing. Regular expressions themselves, with a general pattern notation almost like a mini programming language, allow you to describe and parse text. When scratch some web information from Internet, I realize the power of Regular Expressions. From today, I will study the RE step by step.

    Some definations or speacial terms should be given first!

    Metacharacters: Full regular expressions are composed of two types of characters. The special characters (like the "+" "." ) are called metacharacters,while
the rest are called literal, or nor mal text characters

    What sets regular expressions part from Œlename patterns are the advanced expressive powers that their metacharacters provide. Filename patterns provide limited metacharacters for limited needs, but a regular expression ™languageš provides rich and expressive metacharacters for advanced uses.

    Egrep:Finding text is one of the simplest uses of regular expressionsŠmany text editors and word processors allow you to search a document using a regular-expr ession pattern. Even simpler is the utility egrep.

    Figure 1 shows you some metachracters that I have learnt from the book "Mastering Regular Expressions"

 

   

    (1) The metacharacter "." (usually called dot or point) is a shorthand for a character class that matches any character.

    Example:

    if you want to search for a date such as 03/19/76, 03-19-76, or even 03.19.76, you could go to the trouble to construct a regular expression that uses character classes to
explicitly allow `/', `-', or `.' between each number, such as 03[-./]19[-./]76.
However, you might also try simply using 03.19.76

   (2) The regular-expression construct "[ ]", usually called a character class.

   Example:

   "[123456]" matches any of the listed digits.

   (3) "[^]" instead of "[]", the class matches any character that isn't listed.

   Example:

       "[^1-6]" matches a character that's not 1 thr ough 6.

   Continue:::::

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值