Search code examples
regexzabbix

Regex to match hyphen between two specific words surrounded by square brackets


I need to match the following with Regex

[zabbix-frontend]

I have started with the following, but I do not know how I can capture the hyphen - and the following word and bracket

^\[zabbix

Any advice is greatly appreciated.

I have only tried this so far amongst other things, but cannot get a match on the words as above. ^\[zabbix


Solution

  • The following regular expression can be used to match only the string "[zabbix-frontend]":

    /\[zabbix-frontend\]/