Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/algorithms/string.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ def string_concat(n):


def regex_match(strings: list[str], pattern: str) -> list[str]:
# Compile pattern once for better performance when used repeatedly
regex = re.compile(pattern)
matched = []
for s in strings:
if re.match(pattern, s):
if regex.match(s):
matched.append(s)
return matched

Expand Down