Javascript examples for String:replace
Filter Spaces around all hyphens in a string without double-up
<html> <head></head> <body> <script> var instr = "jaguar-leopard\n"+ "jaguar -leopard\n"+ "jaguar- leopard\n"+ "jaguar - leopard"; instr=instr.replace(/(\S)-/g,'$1 -').replace(/-(?=\S)/g,'- '); console.log(instr); </script> </body>/*from w ww .j a va2 s . c o m*/ </html>