Question: I have the following string example:

```
[14:48:51.690] LOGON           error group: 103

```

I get many different from them. The only thing is, that the beginning is always the same expect the date (always in brackets) and name of `LOGON`. I want to remove thi in front. 
How can I achieve this efficiently? Regex? Splitting and remove from array?

The only thing I want to have finally is

```
error group: 103

```

Answer: 
You can split the string based on regex `\[\d{1,2}:\d{1,2}:\d{1,2}\.\d{1,3}\]\s*\w*\s*`

```
import java.util.regex.Pattern;

public class T {

    public static void main(String[] args) {
        String s = "[14:48:51.690] LOGON           error group: 103";

        String[] split = s.split("\\[\\d{1,2}:\\d{1,2}:\\d{1,2}\\.\\d{1,3}\\]\\s*\\w*\\s*");

        System.out.println(split[1]);
    }
}

```

Output

```
error group: 103

```
Here is another way using a simple regular expression:

```
    Pattern pattern = Pattern.compile("\\[.*\\]\\s*LOGON\\s*(.*)\\s*");

    Matcher matcher = pattern.matcher("[14:48:51.690] LOGON           error group: 103");
    if (matcher.find()) {
        System.out.println(matcher.group(1));           
    }

```

So essentially we scan the opening bracket, the date inside it, the closing bracket, any whitespace
in between until and capture the part you're looking for using `(.*)`.