-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a504346
commit e9d620e
Showing
1 changed file
with
20 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |