var str='abc:target12 target12 cdtarget23 target';print(str.replace(/target\d{2}/g, 'ok'));
Standard input is empty
abc:ok ok cdok target
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!