in reply to Re^2: Help with pattern matching
in thread Help with pattern matching

Ah. And it didn’t occur to you that people would need example data that shows all the possible scenarios to be able to solve your problem? :-)

Is the relay= bit always the last part of the line? In that case you could just use

m{ relay= \[? (.*) \]? }msx

If not, then it is probably followed by a comma or end of line (again, can’t know without more sample data), so what you need is

m{ relay= \[? (.*?) \]? (:? \Z | , ) }msx

Note that while I’m using a lazy quantifier in the second case (which is what is causing the problems in your patterns), it is followed by a non-optional part of the regex, so it will always be forced to consume as much as necessary to make the overall pattern match.

Makeshifts last the longest.