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: 
Split on **space followed by comma**:

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

```

`[\\s,]` is a character class and it will split on space or comma.
Use this to split a string when a white space, then comma occurs.

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

```