$regex = /(^)(\[(.*)\]) (.*)$/; 

Regex takes all chat messages of the form:

 [Помощь] Джон: ... 

The problem is that the chat also contains lines like:

 [ ] Служебная информация: ... [ >Важно< ] ... [ >>> ] ... [ <<< ] ... 

That is, in fact, I need to exclude the lines where at the beginning between [ and ] :

  • There are only spaces and / or characters > and <
  • There is only an inscription важно , with spaces and signs < , > or without

In this case, the space, the characters > and < may occur in other cases, but if there are also other characters between [ and ] , then such a line should be taken

 [Общий] Джон: Привет [ > СТАТУС < ] ... [ >>> 45] ... 

    1 answer 1

    Sort of:

     $regex = /^\[(?![\s<>]*\])(.*?)\] (.*)$/; 

    https://regex101.com/r/cA4vH0/1