我正在使用pyqt构建文本编辑器,我想设置字体STYLES [错误]时(“)不以另一个(”)结束,当它正确设置字体STYLES [string]时,我的问题是什么时候(“ “)结束...(”“之后的任何字符采用字体STYLES [错误]我想停止它但不能设置正确的正则表达式
`
STYLES = {
'string' : format('magenta') ,
'error' : format('red' , 'underline') ,
}
rules +=[(r'"[^"\\]*(\\.[^"\\]*)*', 0, STYLES['error']),
(r'"[^"\\]*(\\.[^"\\]*)*"', 0, STYLES['string']),]
`
答案 0 :(得分:0)
试一试:
## error
(r'"[^"\\]*(\\.[^"\\]*)*.', 0, STYLES['error']),
(r"'[^'\\]*(\\.[^'\\]*)*.", 0, STYLES['error']),
# Double-quoted string, possibly containing escape sequences
(r'"[^"\\]*(\\.[^"\\]*)*"', 0, STYLES['string']),
# Single-quoted string, possibly containing escape sequences
(r"'[^'\\]*(\\.[^'\\]*)*'", 0, STYLES['string']),