20 @return tuple of flag indicating validity (boolean), error |
20 @return tuple of flag indicating validity (boolean), error |
21 string (string) and error offset (integer) |
21 string (string) and error offset (integer) |
22 """ |
22 """ |
23 try: |
23 try: |
24 from PyQt5.QtCore import QRegularExpression |
24 from PyQt5.QtCore import QRegularExpression |
25 rxOptions = QRegularExpression.NoPatternOption |
25 rxOptions = QRegularExpression.PatternOption.NoPatternOption |
26 if "CaseInsensitiveOption" in options: |
26 if "CaseInsensitiveOption" in options: |
27 rxOptions |= QRegularExpression.CaseInsensitiveOption |
27 rxOptions |= QRegularExpression.PatternOption.CaseInsensitiveOption |
28 if "MultilineOption" in options: |
28 if "MultilineOption" in options: |
29 rxOptions |= QRegularExpression.MultilineOption |
29 rxOptions |= QRegularExpression.PatternOption.MultilineOption |
30 if "DotMatchesEverythingOption" in options: |
30 if "DotMatchesEverythingOption" in options: |
31 rxOptions |= QRegularExpression.DotMatchesEverythingOption |
31 rxOptions |= ( |
|
32 QRegularExpression.PatternOption.DotMatchesEverythingOption |
|
33 ) |
32 if "ExtendedPatternSyntaxOption" in options: |
34 if "ExtendedPatternSyntaxOption" in options: |
33 rxOptions |= QRegularExpression.ExtendedPatternSyntaxOption |
35 rxOptions |= ( |
|
36 QRegularExpression.PatternOption.ExtendedPatternSyntaxOption |
|
37 ) |
34 if "InvertedGreedinessOption" in options: |
38 if "InvertedGreedinessOption" in options: |
35 rxOptions |= QRegularExpression.InvertedGreedinessOption |
39 rxOptions |= ( |
|
40 QRegularExpression.PatternOption.InvertedGreedinessOption |
|
41 ) |
36 if "UseUnicodePropertiesOption" in options: |
42 if "UseUnicodePropertiesOption" in options: |
37 rxOptions |= QRegularExpression.UseUnicodePropertiesOption |
43 rxOptions |= ( |
|
44 QRegularExpression.PatternOption.UseUnicodePropertiesOption |
|
45 ) |
38 if "DontCaptureOption" in options: |
46 if "DontCaptureOption" in options: |
39 rxOptions |= QRegularExpression.DontCaptureOption |
47 rxOptions |= QRegularExpression.PatternOption.DontCaptureOption |
40 |
48 |
41 error = "" |
49 error = "" |
42 errorOffset = -1 |
50 errorOffset = -1 |
43 re = QRegularExpression(regexp, rxOptions) |
51 re = QRegularExpression(regexp, rxOptions) |
44 valid = re.isValid() |
52 valid = re.isValid() |
69 valid, error, errorOffset = rxValidate(regexp, options) |
77 valid, error, errorOffset = rxValidate(regexp, options) |
70 if not valid: |
78 if not valid: |
71 return valid, error, errorOffset |
79 return valid, error, errorOffset |
72 |
80 |
73 from PyQt5.QtCore import QRegularExpression |
81 from PyQt5.QtCore import QRegularExpression |
74 rxOptions = QRegularExpression.NoPatternOption |
82 rxOptions = QRegularExpression.PatternOption.NoPatternOption |
75 if "CaseInsensitiveOption" in options: |
83 if "CaseInsensitiveOption" in options: |
76 rxOptions |= QRegularExpression.CaseInsensitiveOption |
84 rxOptions |= QRegularExpression.PatternOption.CaseInsensitiveOption |
77 if "MultilineOption" in options: |
85 if "MultilineOption" in options: |
78 rxOptions |= QRegularExpression.MultilineOption |
86 rxOptions |= QRegularExpression.PatternOption.MultilineOption |
79 if "DotMatchesEverythingOption" in options: |
87 if "DotMatchesEverythingOption" in options: |
80 rxOptions |= QRegularExpression.DotMatchesEverythingOption |
88 rxOptions |= ( |
|
89 QRegularExpression.PatternOption.DotMatchesEverythingOption |
|
90 ) |
81 if "ExtendedPatternSyntaxOption" in options: |
91 if "ExtendedPatternSyntaxOption" in options: |
82 rxOptions |= QRegularExpression.ExtendedPatternSyntaxOption |
92 rxOptions |= ( |
|
93 QRegularExpression.PatternOption.ExtendedPatternSyntaxOption |
|
94 ) |
83 if "InvertedGreedinessOption" in options: |
95 if "InvertedGreedinessOption" in options: |
84 rxOptions |= QRegularExpression.InvertedGreedinessOption |
96 rxOptions |= QRegularExpression.PatternOption.InvertedGreedinessOption |
85 if "UseUnicodePropertiesOption" in options: |
97 if "UseUnicodePropertiesOption" in options: |
86 rxOptions |= QRegularExpression.UseUnicodePropertiesOption |
98 rxOptions |= ( |
|
99 QRegularExpression.PatternOption.UseUnicodePropertiesOption |
|
100 ) |
87 if "DontCaptureOption" in options: |
101 if "DontCaptureOption" in options: |
88 rxOptions |= QRegularExpression.DontCaptureOption |
102 rxOptions |= QRegularExpression.PatternOption.DontCaptureOption |
89 |
103 |
90 matched = False |
104 matched = False |
91 captures = [] |
105 captures = [] |
92 re = QRegularExpression(regexp, rxOptions) |
106 re = QRegularExpression(regexp, rxOptions) |
93 match = re.match(text, startpos) |
107 match = re.match(text, startpos) |