QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 991|回复: 1

正则表达式匹配问题

[复制链接]
发表于 2005-12-29 16:43:40 | 显示全部楼层 |阅读模式
想匹配一些字符串出来,使用正则表达式应该如何编写?
1. 匹配双引号内的内容(最小匹配,且不认为\"为双引号),例如
"this is a test" -> this is a test
"\"string\"" -> \"string\"

2. 匹配大括号里的内容(最小匹配,且不认为双引号内的{}为大括号),例如
{this is a test} -> this is a test
{this is a "test"} -> this is a "test"
{this is a "{test}"} -> this is a "{test}"
发表于 2006-1-3 21:05:32 | 显示全部楼层
\"string\" --->\\\"string\\\"

其它都差不多的,

只需要明白"\"它的用法就行了:
在一些特殊的符號,也就是coding時會用到的那些符號,比如:“/” 加上"\" 後程式會將其當成字符來處理;
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-7-3 10:10 , Processed in 0.086998 second(s), 16 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表