learn-regex icon indicating copy to clipboard operation
learn-regex copied to clipboard

how to give url pattern to search for values like "L76255 - Manual Call Point" . values which contains whitespaces ?

Open rishi1804 opened this issue 5 years ago • 3 comments

I am making API in django and for that, I need to give a path in URL pattern to match values like L76255 - Manual Call Point
please help @arxenix @ponsfrilus @loisaidasam

rishi1804 avatar Jan 31 '20 09:01 rishi1804

Hi @rishi1804 , can you provide more detail?

So the pattern can be letters, numbers, dashes, and spaces? Any specific order?

Maybe something like:

[\w\-\s]+

(Some amount of alphanumeric characters/hyphens/spaces)

🤷‍♀️

loisaidasam avatar Jan 31 '20 16:01 loisaidasam

@loisaidasam yes the pattern can consist of letters, numbers, dashes, and spaces, for example, I need to match values like L76255 - Manual Call Point while making URL patterns in Django

rishi1804 avatar Feb 03 '20 06:02 rishi1804

def get_asset_deatils_by_class(request,slug): connections.create_connection(hosts=['localhost'], timeout=20) client = Elasticsearch() s = Search(using=client, index='assets').query("match",class__raw=slug) response = s.execute() list1 = response.to_dict() return JsonResponse(list1)

this is the code and here the slug argument is going to be of the form L76255 - Manual Call Point

rishi1804 avatar Feb 03 '20 08:02 rishi1804