Skip to content

Commit

Permalink
Added is_regex.py
Browse files Browse the repository at this point in the history
  • Loading branch information
nmassey001 committed Oct 6, 2024
1 parent a504346 commit e9d620e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions nlds_processors/utils/is_regex.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# encoding: utf-8
"""
is_regex.py
"""
__author__ = "Neil Massey"
__date__ = "03 Oct 2024"
__copyright__ = "Copyright 2024 United Kingdom Research and Innovation"
__license__ = "BSD - see LICENSE file in top-level package directory"
__contact__ = "[email protected]"

def is_regex(input: str) -> bool:
"""Check whether the input string contains regular expressions."""
regex_matches = (
'[', ']', '{', '}', '^', '|', '\s', '\S', '\d', '\D', '\w', '\W',
'(:?', '(', ')', '?', '*', '+', '$', '\b', '\B'
)
for r in regex_matches:
if r in input:
return True
return False

0 comments on commit e9d620e

Please sign in to comment.