How to find all characters to brackets [img], Through exec or match ? also read information between [img] .

Example string:

 Сегодня теплая солнечная погода[img]http://i.imgur.com/E9talog.png[/img], но передают что заврата будет[img]http://i.imgur.com/E9talog2222.png[/img]дождь.[img]http://i.imgur.com/E9talog333.png[/img] 

Expect something like this:

 Сегодня теплая солнечная погода http://i.imgur.com/E9talog.png но передают что заврата будет http://i.imgur.com/E9talog2222.png дождь. http://i.imgur.com/E9talog333.png 
  • What does "to brackets" mean? What result do you expect to get for the given string? - Dmitriy Simushev
  • @Dmitriy Simushev Corrected your message. - gilo1212
  • @Dmitriy Simushev Compiled a more detailed description. - gilo1212

1 answer 1

The easiest option, from those that I see, looks like this:

 /(.*?)\[img\](.*?)\[\/img\]/g 

Working example on Regex101.

  • Thank you very much. And why is it the easiest? What other options are there? - gilo1212
  • Regular expressions are a very powerful mechanism. Each task can be solved in more than one way. As for the other RegExp for your task, now nothing comes to my mind =) - Dmitriy Simushev