Javascript examples for RegExp:RegExp Match
Match besides first word and words starting with one or two hyphens
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/*from ww w.ja v a 2 s. co m*/ var str = 'test --par2 --par23 = asdf 0 aa true hello "test test"'; var re = /("[^"]+")|^\S+|\W-\S+|(\S+)/g; var res = [] while ((m = re.exec(str)) !== null) { if(m[1] != undefined) res.push(m[1]); if(m[2] != undefined) res.push(m[2]); } console.log(res); } </script> </head> <body> </body> </html>