375 Private slot to validate the entered regexp. |
375 Private slot to validate the entered regexp. |
376 """ |
376 """ |
377 regex = self.regexpTextEdit.toPlainText() |
377 regex = self.regexpTextEdit.toPlainText() |
378 if regex: |
378 if regex: |
379 try: |
379 try: |
|
380 flags = 0 |
|
381 if not self.caseSensitiveCheckBox.isChecked(): |
|
382 flags |= re.IGNORECASE |
|
383 if self.multilineCheckBox.isChecked(): |
|
384 flags |= re.MULTILINE |
|
385 if self.dotallCheckBox.isChecked(): |
|
386 flags |= re.DOTALL |
|
387 if self.verboseCheckBox.isChecked(): |
|
388 flags |= re.VERBOSE |
380 if self.py2Button.isChecked(): |
389 if self.py2Button.isChecked(): |
381 re.compile(regex, |
390 if self.localeCheckBox.isChecked(): |
382 (not self.caseSensitiveCheckBox.isChecked() and re.IGNORECASE or 0) | \ |
391 flags |= re.LOCALE |
383 self.multilineCheckBox.isChecked() and re.MULTILINE or 0 | \ |
392 if self.unicodeCheckBox.isChecked(): |
384 self.dotallCheckBox.isChecked() and re.DOTALL or 0 | \ |
393 flags |= re.UNICODE |
385 self.verboseCheckBox.isChecked() and re.VERBOSE or 0 | \ |
|
386 self.localeCheckBox.isChecked() and re.LOCALE or 0 | \ |
|
387 self.unicodeCheckBox.isChecked() and re.UNICODE or 0) |
|
388 else: |
394 else: |
389 re.compile(regex, |
395 if self.unicodeCheckBox.isChecked(): |
390 (not self.caseSensitiveCheckBox.isChecked() and re.IGNORECASE or 0) | \ |
396 flags |= re.ASCII |
391 self.multilineCheckBox.isChecked() and re.MULTILINE or 0 | \ |
397 re.compile(regex, flags) |
392 self.dotallCheckBox.isChecked() and re.DOTALL or 0 | \ |
|
393 self.verboseCheckBox.isChecked() and re.VERBOSE or 0 | \ |
|
394 (not self.unicodeCheckBox.isChecked() and re.UNICODE or 0)) |
|
395 E5MessageBox.information(self, |
398 E5MessageBox.information(self, |
396 self.trUtf8("Validation"), |
399 self.trUtf8("Validation"), |
397 self.trUtf8("""The regular expression is valid.""")) |
400 self.trUtf8("""The regular expression is valid.""")) |
398 except re.error as e: |
401 except re.error as e: |
399 E5MessageBox.critical(self, |
402 E5MessageBox.critical(self, |
438 if self.localeCheckBox.isChecked(): |
441 if self.localeCheckBox.isChecked(): |
439 flags |= re.LOCALE |
442 flags |= re.LOCALE |
440 if self.unicodeCheckBox.isChecked(): |
443 if self.unicodeCheckBox.isChecked(): |
441 flags |= re.UNICODE |
444 flags |= re.UNICODE |
442 else: |
445 else: |
443 if not self.unicodeCheckBox.isChecked(): |
446 if self.unicodeCheckBox.isChecked(): |
444 flags |= re.UNICODE |
447 flags |= re.ASCII |
445 regobj = re.compile(regex, flags) |
448 regobj = re.compile(regex, flags) |
446 matchobj = regobj.search(text, startpos) |
449 matchobj = regobj.search(text, startpos) |
447 if matchobj is not None: |
450 if matchobj is not None: |
448 captures = len(matchobj.groups()) |
451 captures = len(matchobj.groups()) |
449 if captures is None: |
452 if captures is None: |