Question: I want to replace the following types:

```
Some Query String
Some Comma, Separated, Query String

```

With the following:

```
Some-Query-String
Some-Comma-Separated-Query-String

```

Any ideas on the regular expression for this?

Answer: 
This should do what you want `/,?\s+/g`

```
'Some Comma, Seperated, Query String'.replace(/,?\s+/g, '-');
// Will produce: "Some-Comma-Seperated-Query-String"

```
```
,?[ ]

```

Try this.Replace by `-`.See demo.

<http://regex101.com/r/yR3mM3/14>

```
var re = /,?[ ]/g;
var str = 'Some Query String\nSome Comma, Seperated, Query String';
var subst = '-';

var result = str.replace(re, subst);

```