re = /([A-Z^\.]+\.(?:[^\[]+| ?)\[[^\]]+[^\s]+)/m
str = 'VB.Bar-1[TEST-Insert.2]Val_1 = B.Bar-1[PC83-AB2.1]In1 && B.Bar-1[PC83-AB2.1]In2
VB.Bilozerka-1[TEST-Insert.2]Val_2 = B.Bilozerka-1[ТП1.1]Пуск_захисту && B.Bilozerka-1[ТП1.1]Спрацьовування_захисту_iнвертора
VA.Bar-1[TEST-Insert.3]Val_3 = A.Bar-1[DirisA40.1]V3 && A.Bar-1[DirisA40.1]P
VA.Dashev-1[TEST-Insert.3]Val_1 = A.Dashev-1[ТП-5.2 AC]C_active_power && B.Dashev-1[ТП-5.2 AC]PV_input_power'
# Print the match result
str.scan(re) do |match|
puts match.to_s
end
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Ruby, please visit: http://ruby-doc.org/core-2.2.0/Regexp.html