您的位置:首页 > 编程语言 > Python开发

Python 正则表达式验证字符串(可能带转义符)

2014-09-25 10:54 411 查看
1.Match a string enclosed by double quotes (strings with escapes, no line break)
"[^"\\\r\n]*(?:\\.[^"\\\r\n]*)"

2.Match a string enclosed by single quotes (strings with escapes, no line break)
'[^'\\\r\n]*(?:\\.[^'\\\r\n]*)'

3.Match a string enclosed by single or double qutoes (strings with escapes, no line break)
"[^"\\\r\n]*(?:\\.[^"\\\r\n]*)"|'[^'\\\r\n]*(?:\\.[^'\\\r\n]*)'

4.Match a string enclosed by double qutoes (strings with escapes, may have escaped line break)
"[^"\\\r\n]*(?:\\(?:.|\r?\n)[^"\\\r\n]*)"

5.Match a string enclosed by double qutoes (strings with escapes, may have line break)
"[^"\\]*(?:\\.[^"\\]*)*"
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: