-2

Is there anyone who can help me to get the marked pieces out of this file (see image below) with a regular expression? As you can see, it's difficult because the length is not always the same and the part before my goal is sometimes broken down and sometimes not.

enter image description here

Thank you in advance.

Text:

:61:200106D48,66NDDTEREF//00060100142533 /TRCD/01028/ :86:/EREF/SLDD-0705870-5658387529//MARF/11514814-001//CSID/NL59ZZZ390 373820000//CNTP/NL96ABNA0123456789/ABCANL2A/XXXXXXX123///REMI/UST D//N00814760/ :61:200106D1840,55NDDTEREF//00060100142534 /TRCD/01028/ :86:/EREF/SLDD-0705869-5658387528//MARF/11514814-001//CSID/NL59ZZZ390 373820000//CNTP/NL96ABNA0123456789/ABCANL2A/XXX123XXXX///REMI/UST D//N00814759/ :61:200106C236,31NTRFEREF//00060100142535 /TRCD/00100/ :86:/EREF/05881000010520//CNTP/NL19INGB0123456789/ABCBNL2A/XX123XXXX// /REMI/USTD//KLM REF 1000000022/

  • 1
    Hi, welcome to stackoverflow ! could you add a text version of one of those string,it will really help us. – Nicolas Jan 08 '20 at 16:06
  • Hi Nicolas, Thanks for your reaction. I am pretty new here and this is not really my cup of tea ;-) I added the text. – Bas Romeijn Jan 09 '20 at 08:11

1 Answers1

0

The length is not always the same but it does not really matter in your case. You can check for a particular pattern at the end of a string.

(?<=\/\/)([\u2022a-zA-Z0-9]+)(?=\/$)

this regex will look for a string of caracter containing bullet (), numbers, letters (uppercase and lowercase), that followes two front slash (//) and is followed by a slash (/) and the end of the string ( $ ).

You can test more cases here

Nicolas
  • 7,276
  • 3
  • 17
  • 40