-1

I'd like to extract multiple values from the below sentance

var memo = 'BRD-35/21/9: DSI-35/21/641 - 154.0, DSI-35/21/617 - 84.0, TI-23/21223/12 - 78.98';

console.log(memo.match(/DSI\w*/g));

I'd like to get result as ['DSI-35/21/641', 'DSI-35/21/617', 'TI-23/21223/12']

Thanks in advance.

2 Answers2

0

Maybe something like this:

    var memo = 'BRD-35/21/9: DSI-35/21/641 - 154.0, DSI-35/21/617 - 84.0, TI-23/21223/12 - 78.98';
    console.log([...memo.matchAll(/[,|:]\s([A-Z0-9\/-]*)/g)].map(function(el){return el[1];}));
Flash Thunder
  • 11,672
  • 8
  • 47
  • 91
-1

The following regex should do what you want:

(DSI|TI)-\d+\/\d+\/\d+

Match DSI or TI followed by a -, then 3 digits separated by /.

match
  • 10,388
  • 3
  • 23
  • 41