Question: I want to split a string when space is followed by comma.

My input String :

```
go back, to work !  ,2012-10-01 07:01:45,,  1

```

Output Expected:

```
"go back, to work !"    
"2012-10-01 07:01:45,,1"

```

Code I tried: 

```
String[] b1=a1.split("[\\s,]");

```

But this splits the string only based on whitespaces. I want to split it when there is both whitespace and comma not just either one. What should I do?

Answer: 
Use this to split a string when a white space, then comma occurs.

```
String[] b1 = a1.split(" ,");

```
Split on space followed by comma using `("\\s,")` will not give you the desired output of 

```
"go back, to work !"

"2012-10-01 07:01:45"

1

```

The output will be 

```
go back, to work !

2012-10-01 07:01:45,, 1

```

Either you can use comma followed by space or space followed by comma using `"\\s,|,\\s"` then you will get below output

```
go back

to work !

2012-10-01 07:01:45,

1

```

However it's still not same as what you wanted. You might want to clarify your requirement.