0

Assuming this string

123_4,56776_17,_,99997_1,_,87969_3,_,_,_,_,_,_,_,456_9

My desired output is:

123_4,56776_17,99997_1,87969_3,456_9

My regex appears to do the trick here https://regex101.com/r/dXtrph/1 :

(?<=)\d+_\d+(?=)

But no output in JS code. Is there an issue with the underscore?

var strng = '123_4,56776_17,_,99997_1,_,87969_3,_,_,_,_,_,_,_,456_9';
var rgx = /(?<=)\d+_\d+(?=);  
var outstrng = strng.match(rgx).join(',');
Write(outstrng); 
apples-oranges
  • 959
  • 2
  • 9
  • 21
  • 1
    You do not need the empty lookarounds. And you missed the trailing `/g`. `var rgx = /\d+_\d+/g;`. Please make sure you also check [code generator page](https://regex101.com/r/dXtrph/1/codegen?language=javascript) when you are not sure what the regex looks like in the code. – Wiktor Stribiżew Jun 04 '21 at 16:47
  • That worked, thank you! :-) – apples-oranges Jun 04 '21 at 19:19

0 Answers0