0

i am building text editor with pyqt and i want to set font STYLES[error] when (") not end with another (") , and when it end correctly set font STYLES[string] , my problem is when ("") ending ... any character after ("") takes font STYLES[error] and i want to stop it but can't set correct regular expression

`
STYLES = {
    'string'   : format('magenta') ,
    'error'    : format('red' , 'underline') ,
}
rules +=[(r'"[^"\\]*(\\.[^"\\]*)*', 0, STYLES['error']),
         (r'"[^"\\]*(\\.[^"\\]*)*"', 0, STYLES['string']),]
`
Hunterx01
  • 39
  • 7

1 Answers1

0

Try it:

        ## 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']),

enter image description here

S. Nick
  • 12,879
  • 8
  • 25
  • 33
  • thanks it's work for me , can you help me to write re that set font [error] if ";" not written in end of line . – Hunterx01 Apr 22 '18 at 10:42