Exemplo n.º 1
0
    def __init__(self, string, parent=None):
        super().__init__(parent)

        self.fmt = QtGui.QTextCharFormat()
        self.fmt.setBackground(QtCore.Qt.GlobalColor.lightGray)
        self.reg = re.compile(wildcards_to_regex_pattern(string),
                              re.IGNORECASE)
Exemplo n.º 2
0
 def test_special_chars(self):
     pattern = ']()\\^$|'
     regex = wildcards_to_regex_pattern(pattern)
     self.assertEqual(re.escape(pattern), regex)
     re.compile(regex)
Exemplo n.º 3
0
 def test_open_character_group(self):
     pattern = '[abc*?xyz['
     regex = wildcards_to_regex_pattern(pattern)
     self.assertEqual('\\[abc.*.xyz\\[', regex)
     re.compile(regex)
Exemplo n.º 4
0
 def test_character_group_escape_square_brackets(self):
     pattern = '[a[b\\]c]'
     regex = wildcards_to_regex_pattern(pattern)
     self.assertEqual('[a[b\\]c]', regex)
     re.compile(regex)
Exemplo n.º 5
0
 def test_character_group(self):
     pattern = '[abc*?xyz]]'
     regex = wildcards_to_regex_pattern(pattern)
     self.assertEqual('[abc*?xyz]\\]', regex)
     re.compile(regex)
Exemplo n.º 6
0
 def test_escape(self):
     pattern = 'f\\?o\\*o?o*\\[o'
     regex = wildcards_to_regex_pattern(pattern)
     self.assertEqual('f\\?o\\*o.o.*\\[o', regex)
     re.compile(regex)
Exemplo n.º 7
0
 def test_wildcard_pattern(self):
     pattern = 'fo?o*'
     regex = wildcards_to_regex_pattern(pattern)
     self.assertEqual('fo.o.*', regex)
     re.compile(regex)