-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRegexList.py
More file actions
36 lines (32 loc) · 1.37 KB
/
RegexList.py
File metadata and controls
36 lines (32 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# ----------------------------------------------------------------
# Author: wayneferdon wayneferdon@hotmail.com
# Date: 2022-10-05 16:15:12
# LastEditors: WayneFerdon wayneferdon@hotmail.com
# LastEditTime: 2023-03-04 13:12:24
# FilePath: \Flow.Launcher.Plugin.ChromeBookmarks\RegexList.py
# ----------------------------------------------------------------
# Copyright (c) 2022 by Wayne Ferdon Studio. All rights reserved.
# Licensed to the .NET Foundation under one or more agreements.
# The .NET Foundation licenses this file to you under the MIT license.
# See the LICENSE file in the project root for more information.
# ----------------------------------------------------------------
# -*- coding: utf-8 -*-
import re
class RegexList:
def __init__(self, queryString: str):
self.queryString = queryString
queryList = RegexList.__replaceBrackets__(queryString).lower().split()
self.__regexs__ = [ re.compile(x) for x in queryList ]
def __replaceBrackets__(string:str):
try:
return string.replace('[', '\[') \
.replace(']', '\]') \
.replace('(', '\(') \
.replace(')', '\)')
except Exception as e:
return string
def match(self, item: str):
for regex in self.__regexs__:
if not regex.search(item.lower()):
return False
return True