Skip to content

Commit

Permalink
Use re.compile instead of now deprecated sre_compile
Browse files Browse the repository at this point in the history
  • Loading branch information
kunaltyagi committed Oct 27, 2024
1 parent ff8d02a commit 5718ab7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions nsiqcppstyle_rulehelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import sre_compile
import re

import nsiqcppstyle_state

Expand All @@ -38,21 +38,21 @@ def Match(pattern, s):
# performance reasons; factoring it out into a separate function turns out
# to be noticeably expensive.
if pattern not in _regexp_compile_cache:
_regexp_compile_cache[pattern] = sre_compile.compile(pattern)
_regexp_compile_cache[pattern] = re.compile(pattern)
return _regexp_compile_cache[pattern].match(s)


def Search(pattern, s):
"""Searches the string for the pattern, caching the compiled regexp."""
if pattern not in _regexp_compile_cache:
_regexp_compile_cache[pattern] = sre_compile.compile(pattern)
_regexp_compile_cache[pattern] = re.compile(pattern)
return _regexp_compile_cache[pattern].search(s)


def FindAll(pattern, s):
"""Searches the string for the pattern, caching the compiled regexp."""
if pattern not in _regexp_compile_cache:
_regexp_compile_cache[pattern] = sre_compile.compile(pattern)
_regexp_compile_cache[pattern] = re.compile(pattern)
return _regexp_compile_cache[pattern].findall(s)


Expand Down

0 comments on commit 5718ab7

Please sign in to comment.