正则表达式匹配问题
想匹配一些字符串出来,使用正则表达式应该如何编写?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}" \"string\" --->\\\"string\\\"
其它都差不多的,
只需要明白"\"它的用法就行了:
在一些特殊的符號,也就是coding時會用到的那些符號,比如:“/” 加上"\" 後程式會將其當成字符來處理;
页:
[1]