16 |
16 |
17 def rxValidate(regexp, options): |
17 def rxValidate(regexp, options): |
18 """ |
18 """ |
19 Function to validate the given regular expression. |
19 Function to validate the given regular expression. |
20 |
20 |
21 @param regexp regular expression to validate (string) |
21 @param regexp regular expression to validate |
22 @param options list of options (list of string) |
22 @type str |
23 @return tuple of flag indicating validity (boolean), error |
23 @param options list of options |
24 string (string) and error offset (integer) |
24 @type list of str |
|
25 @return tuple of flag indicating validity, error string and error offset |
|
26 @rtype tuple of (bool, str, int) |
25 """ |
27 """ |
26 rxOptions = QRegularExpression.PatternOption.NoPatternOption |
28 rxOptions = QRegularExpression.PatternOption.NoPatternOption |
27 if "CaseInsensitiveOption" in options: |
29 if "CaseInsensitiveOption" in options: |
28 rxOptions |= QRegularExpression.PatternOption.CaseInsensitiveOption |
30 rxOptions |= QRegularExpression.PatternOption.CaseInsensitiveOption |
29 if "MultilineOption" in options: |
31 if "MultilineOption" in options: |
52 |
54 |
53 def rxExecute(regexp, options, text, startpos): |
55 def rxExecute(regexp, options, text, startpos): |
54 """ |
56 """ |
55 Function to execute the given regular expression for a given text. |
57 Function to execute the given regular expression for a given text. |
56 |
58 |
57 @param regexp regular expression to validate (string) |
59 @param regexp regular expression to validate |
58 @param options list of options (list of string) |
60 @type str |
59 @param text text to execute on (string) |
61 @param options list of options |
60 @param startpos start position for the execution (integer) |
62 @type list of str |
61 @return tuple of a flag indicating a successful match (boolean) and |
63 @param text text to execute on |
62 a list of captures containing the complete match as matched string |
64 @type str |
63 (string), match start (integer), match end (integer) and match length |
65 @param startpos start position for the execution |
64 (integer) for each entry |
66 @type int |
|
67 @return tuple of a flag indicating a successful match and a list of captures |
|
68 containing the complete match as matched string, match start, match end |
|
69 and match length for each entry |
|
70 @rtype tuple of (bool, list of [str, int, int, int]) |
65 """ |
71 """ |
66 valid, error, errorOffset = rxValidate(regexp, options) |
72 valid, error, errorOffset = rxValidate(regexp, options) |
67 if not valid: |
73 if not valid: |
68 return valid, error, errorOffset |
74 return valid, error, errorOffset |
69 |
75 |