本文整理汇总了Python中PyQt5.QtCore.QRegExp.setCaseSensitivity方法的典型用法代码示例。如果您正苦于以下问题:Python QRegExp.setCaseSensitivity方法的具体用法?Python QRegExp.setCaseSensitivity怎么用?Python QRegExp.setCaseSensitivity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtCore.QRegExp
的用法示例。
在下文中一共展示了QRegExp.setCaseSensitivity方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_validateButton_clicked
# 需要导入模块: from PyQt5.QtCore import QRegExp [as 别名]
# 或者: from PyQt5.QtCore.QRegExp import setCaseSensitivity [as 别名]
def on_validateButton_clicked(self):
"""
Private slot to validate the entered regexp.
"""
regex = self.regexpLineEdit.text()
if regex:
re = QRegExp(regex)
if self.caseSensitiveCheckBox.isChecked():
re.setCaseSensitivity(Qt.CaseSensitive)
else:
re.setCaseSensitivity(Qt.CaseInsensitive)
re.setMinimal(self.minimalCheckBox.isChecked())
re.setPatternSyntax(
self.syntaxCombo.itemData(self.syntaxCombo.currentIndex()))
if re.isValid():
E5MessageBox.information(
self,
self.tr("Validation"),
self.tr("""The regular expression is valid."""))
else:
E5MessageBox.critical(
self,
self.tr("Error"),
self.tr("""Invalid regular expression: {0}""")
.format(re.errorString()))
return
else:
E5MessageBox.critical(
self,
self.tr("Error"),
self.tr("""A regular expression must be given."""))
示例2: refresh
# 需要导入模块: from PyQt5.QtCore import QRegExp [as 别名]
# 或者: from PyQt5.QtCore.QRegExp import setCaseSensitivity [as 别名]
def refresh(self):
self.setUpdatesEnabled(False)
pattern = self.patternComboBox.currentText()
text = self.textComboBox.currentText()
escaped = str(pattern)
escaped.replace('\\', '\\\\')
escaped.replace('"', '\\"')
self.escapedPatternLineEdit.setText('"' + escaped + '"')
rx = QRegExp(pattern)
cs = Qt.CaseSensitive if self.caseSensitiveCheckBox.isChecked() else Qt.CaseInsensitive
rx.setCaseSensitivity(cs)
rx.setMinimal(self.minimalCheckBox.isChecked())
syntax = self.syntaxComboBox.itemData(self.syntaxComboBox.currentIndex())
rx.setPatternSyntax(syntax)
palette = self.patternComboBox.palette()
if rx.isValid():
palette.setColor(QPalette.Text,
self.textComboBox.palette().color(QPalette.Text))
else:
palette.setColor(QPalette.Text, Qt.red)
self.patternComboBox.setPalette(palette)
self.indexEdit.setText(str(rx.indexIn(text)))
self.matchedLengthEdit.setText(str(rx.matchedLength()))
for i in range(self.MaxCaptures):
self.captureLabels[i].setEnabled(i <= rx.captureCount())
self.captureEdits[i].setEnabled(i <= rx.captureCount())
self.captureEdits[i].setText(rx.cap(i))
self.setUpdatesEnabled(True)
示例3: hasEnvironmentEntry
# 需要导入模块: from PyQt5.QtCore import QRegExp [as 别名]
# 或者: from PyQt5.QtCore.QRegExp import setCaseSensitivity [as 别名]
def hasEnvironmentEntry(key):
"""
Module function to check, if the environment contains an entry.
@param key key of the requested environment entry (string)
@return flag indicating the presence of the requested entry (boolean)
"""
filter = QRegExp("^%s[ \t]*=" % key)
if isWindowsPlatform():
filter.setCaseSensitivity(Qt.CaseInsensitive)
entries = QProcess.systemEnvironment().filter(filter)
return entries.count() > 0
示例4: getEnvironmentEntry
# 需要导入模块: from PyQt5.QtCore import QRegExp [as 别名]
# 或者: from PyQt5.QtCore.QRegExp import setCaseSensitivity [as 别名]
def getEnvironmentEntry(key, default = None):
"""
Module function to get an environment entry.
@param key key of the requested environment entry (string)
@param default value to be returned, if the environment doesn't contain
the requested entry (string)
@return the requested entry or the default value, if the entry wasn't
found (string or None)
"""
filter = QRegExp("^%s[ \t]*=" % key)
if isWindowsPlatform():
filter.setCaseSensitivity(Qt.CaseInsensitive)
entries = QProcess.systemEnvironment().filter(filter)
if entries.count() == 0:
return default
# if there are multiple entries, just consider the first one
ename, val = unicode(entries[0]).split("=", 1)
return val.strip()
示例5: VariantDelegate
# 需要导入模块: from PyQt5.QtCore import QRegExp [as 别名]
# 或者: from PyQt5.QtCore.QRegExp import setCaseSensitivity [as 别名]
class VariantDelegate(QItemDelegate):
def __init__(self, parent=None):
super(VariantDelegate, self).__init__(parent)
self.boolExp = QRegExp()
self.boolExp.setPattern('true|false')
self.boolExp.setCaseSensitivity(Qt.CaseInsensitive)
self.byteArrayExp = QRegExp()
self.byteArrayExp.setPattern('[\\x00-\\xff]*')
self.charExp = QRegExp()
self.charExp.setPattern('.')
self.colorExp = QRegExp()
self.colorExp.setPattern('\\(([0-9]*),([0-9]*),([0-9]*),([0-9]*)\\)')
self.doubleExp = QRegExp()
self.doubleExp.setPattern('')
self.pointExp = QRegExp()
self.pointExp.setPattern('\\((-?[0-9]*),(-?[0-9]*)\\)')
self.rectExp = QRegExp()
self.rectExp.setPattern('\\((-?[0-9]*),(-?[0-9]*),(-?[0-9]*),(-?[0-9]*)\\)')
self.signedIntegerExp = QRegExp()
self.signedIntegerExp.setPattern('-?[0-9]*')
self.sizeExp = QRegExp(self.pointExp)
self.unsignedIntegerExp = QRegExp()
self.unsignedIntegerExp.setPattern('[0-9]*')
self.dateExp = QRegExp()
self.dateExp.setPattern('([0-9]{,4})-([0-9]{,2})-([0-9]{,2})')
self.timeExp = QRegExp()
self.timeExp.setPattern('([0-9]{,2}):([0-9]{,2}):([0-9]{,2})')
self.dateTimeExp = QRegExp()
self.dateTimeExp.setPattern(self.dateExp.pattern() + 'T' + self.timeExp.pattern())
def paint(self, painter, option, index):
if index.column() == 2:
value = index.model().data(index, Qt.UserRole)
if not self.isSupportedType(value):
myOption = QStyleOptionViewItem(option)
myOption.state &= ~QStyle.State_Enabled
super(VariantDelegate, self).paint(painter, myOption, index)
return
super(VariantDelegate, self).paint(painter, option, index)
def createEditor(self, parent, option, index):
if index.column() != 2:
return None
originalValue = index.model().data(index, Qt.UserRole)
if not self.isSupportedType(originalValue):
return None
lineEdit = QLineEdit(parent)
lineEdit.setFrame(False)
if isinstance(originalValue, bool):
regExp = self.boolExp
elif isinstance(originalValue, float):
regExp = self.doubleExp
elif isinstance(originalValue, int):
regExp = self.signedIntegerExp
elif isinstance(originalValue, QByteArray):
regExp = self.byteArrayExp
elif isinstance(originalValue, QColor):
regExp = self.colorExp
elif isinstance(originalValue, QDate):
regExp = self.dateExp
elif isinstance(originalValue, QDateTime):
regExp = self.dateTimeExp
elif isinstance(originalValue, QTime):
regExp = self.timeExp
elif isinstance(originalValue, QPoint):
regExp = self.pointExp
elif isinstance(originalValue, QRect):
regExp = self.rectExp
elif isinstance(originalValue, QSize):
regExp = self.sizeExp
else:
regExp = QRegExp()
if not regExp.isEmpty():
validator = QRegExpValidator(regExp, lineEdit)
lineEdit.setValidator(validator)
return lineEdit
def setEditorData(self, editor, index):
value = index.model().data(index, Qt.UserRole)
if editor is not None:
editor.setText(self.displayText(value))
#.........这里部分代码省略.........
示例6: regexp
# 需要导入模块: from PyQt5.QtCore import QRegExp [as 别名]
# 或者: from PyQt5.QtCore.QRegExp import setCaseSensitivity [as 别名]
def regexp(self):
re = QRegExp(self.exprEdit.text())
re.setCaseSensitivity(csToQtEnum(self.optionsButton.caseSensitive()))
re.setPatternSyntax(self.optionsButton.reFormat())
return re
示例7: on_executeButton_clicked
# 需要导入模块: from PyQt5.QtCore import QRegExp [as 别名]
# 或者: from PyQt5.QtCore.QRegExp import setCaseSensitivity [as 别名]
def on_executeButton_clicked(self, startpos=0):
"""
Private slot to execute the entered regexp on the test text.
This slot will execute the entered regexp on the entered test
data and will display the result in the table part of the dialog.
@param startpos starting position for the regexp matching
"""
regex = self.regexpLineEdit.text()
text = self.textTextEdit.toPlainText()
if regex and text:
re = QRegExp(regex)
if self.caseSensitiveCheckBox.isChecked():
re.setCaseSensitivity(Qt.CaseSensitive)
else:
re.setCaseSensitivity(Qt.CaseInsensitive)
re.setMinimal(self.minimalCheckBox.isChecked())
syntax = self.syntaxCombo.itemData(self.syntaxCombo.currentIndex())
wildcard = syntax in [QRegExp.Wildcard, QRegExp.WildcardUnix]
re.setPatternSyntax(syntax)
if not re.isValid():
E5MessageBox.critical(
self,
self.tr("Error"),
self.tr("""Invalid regular expression: {0}""")
.format(re.errorString()))
return
offset = re.indexIn(text, startpos)
captures = re.captureCount()
row = 0
OFFSET = 5
self.resultTable.setColumnCount(0)
self.resultTable.setColumnCount(3)
self.resultTable.setRowCount(0)
self.resultTable.setRowCount(OFFSET)
self.resultTable.setItem(
row, 0, QTableWidgetItem(self.tr("Regexp")))
self.resultTable.setItem(row, 1, QTableWidgetItem(regex))
if offset != -1:
self.lastMatchEnd = offset + re.matchedLength()
self.nextButton.setEnabled(True)
row += 1
self.resultTable.setItem(
row, 0, QTableWidgetItem(self.tr("Offset")))
self.resultTable.setItem(
row, 1, QTableWidgetItem("{0:d}".format(offset)))
if not wildcard:
row += 1
self.resultTable.setItem(
row, 0, QTableWidgetItem(self.tr("Captures")))
self.resultTable.setItem(
row, 1, QTableWidgetItem("{0:d}".format(captures)))
row += 1
self.resultTable.setItem(
row, 1, QTableWidgetItem(self.tr("Text")))
self.resultTable.setItem(
row, 2, QTableWidgetItem(self.tr("Characters")))
row += 1
self.resultTable.setItem(
row, 0, QTableWidgetItem(self.tr("Match")))
self.resultTable.setItem(
row, 1, QTableWidgetItem(re.cap(0)))
self.resultTable.setItem(
row, 2,
QTableWidgetItem("{0:d}".format(re.matchedLength())))
if not wildcard:
for i in range(1, captures + 1):
if len(re.cap(i)) > 0:
row += 1
self.resultTable.insertRow(row)
self.resultTable.setItem(
row, 0,
QTableWidgetItem(
self.tr("Capture #{0}").format(i)))
self.resultTable.setItem(
row, 1,
QTableWidgetItem(re.cap(i)))
self.resultTable.setItem(
row, 2,
QTableWidgetItem(
"{0:d}".format(len(re.cap(i)))))
else:
self.resultTable.setRowCount(3)
# highlight the matched text
tc = self.textTextEdit.textCursor()
tc.setPosition(offset)
tc.setPosition(self.lastMatchEnd, QTextCursor.KeepAnchor)
self.textTextEdit.setTextCursor(tc)
else:
self.nextButton.setEnabled(False)
self.resultTable.setRowCount(2)
row += 1
if startpos > 0:
#.........这里部分代码省略.........