Skip to content

Commit

Permalink
update regex
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahesh0253 authored May 18, 2021
1 parent 4f3ed50 commit 6518475
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,13 @@ async def save_file(media):
async def get_search_results(query, file_type=None, max_results=10, offset=0):
"""For given query return (results, next_offset)"""

raw_pattern = query.lower().strip().replace(' ', '[\s\.\+\-_]')
if not raw_pattern:
query = query.strip()
if not query:
raw_pattern = '.'
elif ' ' not in query:
raw_pattern = f'[\b\.\+\-_]{query}[b\.\+\-_]'
else:
raw_pattern = query.replace(' ', '[\s\.\+\-_]')

try:
regex = re.compile(raw_pattern, flags=re.IGNORECASE)
Expand Down

0 comments on commit 6518475

Please sign in to comment.