How to get a string within a string (JS)
Let's say for example, I have the following string in a URL
or
or any other combination. What's the best approach at pulling only the search_query value from the string?
search_query=new%shoes would result in 'New Shoes'.
I need to do this dynamically to account for any size string and any order. I was thinking of using substring and trying to find the nearest index of say = and & or & and (nothing), if there is a case where URL is just
/?search_query=new%shoes&filter=shirts&color=redor
/?filter=jackets&search_query=new%shoes&color=orangeor any other combination. What's the best approach at pulling only the search_query value from the string?
search_query=new%shoes would result in 'New Shoes'.
I need to do this dynamically to account for any size string and any order. I was thinking of using substring and trying to find the nearest index of say = and & or & and (nothing), if there is a case where URL is just
/?search_query=new%shoes