Tell me how to make the choice of the sequence in the expression:

For example links:

http://my.comand.ru/module/processView/show/7?sort={%22todo_list%22:%22a%22}&pci=10&pdi=1&modal_ev=344 localhost:8080/forum/topic-206897: dfsd 

An example of the expression is https://regex101.com/r/XKX0AA/1
Regular expression: ([\w-:\/]*\S+[.\/-]\w*([\w\?]*(((={))|)))

The problem is how to write correctly here: ((= {)) |)) that in 1 case would handle the first link ** http: // * **

I need to get in response to the first link and not to affect the second. Ie from the code you can see that you need to find the ':' character in {} => {key: val} but not find it in the second link. Ie here (localhost: 8080 / forum / topic-206897 :) skip it.

 http://my.comand.ru/module/processView/show/7?sort={%22todo_list%22:%22a%22}&pci=10&pdi=1&modal_ev=344 
  • one
    where does jquery? - Grundy
  • This code is used in my project in juery. I wrote the wrong tag. I see, thank you. - Andrew
  • Why so many brackets? (((={))|) written as (={)? . But what you do not like in your expression and what I should get from the question could not understand - Mike
  • The problem is how to write here correctly: ((= {)) |)) that in 1 case it would process the first link * http: // ** From the text you can see WHAT IS HOW RIGHT. So it is not written there. - Andrew
  • Once again try to formulate the problem so that everyone can understand. You need to handle only those links that have a { ? - PinkTux

1 answer 1

If you need to catch URLs that have something like {...:...} in the query string, then somehow (I do not pretend to absolute correctness):

 [az]+:\/\/\[\w\.\]+\.\[az\]{2,}\S+\?\S+{\S+?:\S+?}\S* 

Test