re = /(?sm)^-(?:(?!^-\r?$).)*?^:86:(?!\/....\/)(?:(?!^-\r?$).)*/
str = '-
:20:296535/00000010
:21:ABNADK2AXXX
:25:ABNADK2AXXX/DK88ABNA0496434500
:28C:42/00002
:60M:C230228EUR124792,65
:61:2302280228C1750,88NTRFC1165-23-00120//656
:86:/TRTP/SEPA OVERBOEKING/IBAN/DK47ABNA0243508514/BIC/ABNADK2A/NAME/
LOOP BV/REMI/AV-RUN 24022023/202301918/EREF/C1165-23-00120
:61:2302280228C4695,98NTRF6381310605374038//656
:86:/TRTP/SEPA OVERBOEKING/IBAN/DK14ABNA0456766324/BIC/ABNADK2A/NAME/
DEV BV/REMI/ID16145 DEB. 1657139 FACT. 202303668 20
2303685 202303689/EREF/638131060537403857-311-2
:61:2302280228C1349,25NTRFNOTPROVIDED//658
:86:/TRTP/SEPA OVERBOEKING/IBAN/DK46ABNA0513892443/BIC/ABNADK2A/NAME/
EXAMPLE COM/REMI/202303656/EREF/NOTPROVIDED
:61:2302280228C55845,96NTRFNOTPROVIDED//658
:86:/TRTP/SEPA OVERBOEKING/IBAN/DK35ABNA0442867689/BIC/ABNADK2A/NAME/
BATH COMPANY DK/REMI/INV. 202228255-8426, OUR REF 2022611
73-79/EREF/NOTPROVIDED
:61:2302280228D105000,NTRFNOTPROVIDED//658
:86:/TRTP/SEPA OVERBOEKING/IBAN/DK98INGB0657624985/BIC/INGBDK2A/NAME/
TEST/REMI/OVERBOEKING/EREF/NOTPROVIDED
:62F:C230228EUR83434,72
:64:C230228EUR83434,72
:86:/ACSI/ABNADK2AXXX
-
:20:STARTUMS TA FW
:25:28020050/0521322890
:28C:017/01
:60F:C230228GBP1473111,27
:61:2302280228D1919,29N020NONREF
:86:206?00AUSL-ZAHLUNG?100004649?20COMPANY?21S LT
D?22TRN AZV2023022800746?23URSP.-BETR.1.900,00 GBP?24KURS 0,87716
0 EUR ZU GBP?25GEGENWERT 2.00,08 EUR?26PROVISION FIX 7
,50 EUR?27SWIFT-/TELE-SPESEN 2,00 EUR?28FREMDE GEB. 12,50 E
UR?2917.02 413337?3028020050?310537246190?32HOMETESTEXAMPLE?33S
LTD?34003
:61:2302280228D16988,81N020NONREF
:86:206?00AUSL-ZAHLUNG?100004649?20BODO GU COM?21NOT A TEST?22TRN
AZV2023022800749?23URSP.-BETR.16.980,48 GBP?24
KURS 0,877160 EUR ZU GBP?25GEGENWERT 19.358,48 EUR?26PROVISIO
N FIX 7,50 EUR?27SWIFT-/TELE-SPESEN 2,00 EUR?2830.01 INV-278
0?29*LOREM*?3028020050?310537246190?32GOLL
?33GOL COM?34003?60INFO 0800-1234
*GEB-FREI*
:61:2302280228D867,06N020NONREF
:86:206?00AUSL-ZAHLUNG?100004649?20NOTACOMPANY?21LTD?2
2TRN AZV2023022800752?23URSP.-BETR.858,73 GBP?24KURS 0,877160 EUR
ZU GBP?25GEGENWERT 978,99 EUR?26PROVISION FIX 7,50 E
UR?27SWIFT-/TELE-SPESEN 2,00 EUR?2828.01 A221322?3028020050?31053
7246190?32KOLL?33LTD?34003
:62F:C230228GBP1453336,11
-'
subst = ''
result = str.gsub(re, subst)
# Print the result of the substitution
puts result
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