const regex = new RegExp('(?<!\\S).(?!\\S)', 'gm')
const str = `a interior Casquillo Dint.50 100
brg aligning Self MM161Z end rod
del eje4 Junta hendidura
352 Junta tórica .20279
2z/C3GJN Rodamiento
pos. Ser. 440PM18002 Interruptor
Reductor SR12013 LF de velocidad
Sick M40Z025023TB1 fotoeléct. Barrera
PR Acoplamiento SA00177
cable 4p Conector micro 4m 889DF4AC5
Brazo actuador 399 largo:
Rodillo 114mm palanca morro largo:
Rodillo 330180000 libre
shaft bar 351819028 Nose
lineal excel Nook Rodamiento
Fotocélula Banner
cable EL03926 Prox. Sensor
EL99942 Ventilador
Cilindro reparado HY00115 hidráulico
SR10510 Reductor velocidad de
barra largo Rodillo de 98mm morro
Rueda horno nivel de centrado
SENSOR:VIBRATION,IP68,500G RANGE,MAX165°
| XSM-3034-30-PP iglidur X sleeve bearing
KIT:HI-TECH,OK143521,O-RING 5/2 WAY,VLV a |
`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
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 JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions