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

```
Regex is a very expensive task. If you're searching into a log file with 100,000 lines, it will take too much time! If your string always has the same pattern, TRY TO TAKE ADVANTAGE OF IT!

I'm assuming your line is: 

```
[some_time] some_event         some event description

```

Simplest way I can see now is just to search for the second space and get everything after it.

```
public class HelloWorld{

     public static void main(String []args){

        String s = "[14:48:51.690] LOGON           error group: 103";
        int pos = getPosOfFirstAlphaNumericCharAfterSecondSpace(s);
        if (pos > 0)
            System.out.println(s.substring(pos));
     }

     private static int getPosOfFirstAlphaNumericCharAfterSecondSpace(String s) {
         int countSpaces = 0;
         for(int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == ' ')
                countSpaces++;
            else if (countSpaces >= 2)
                return i;
         }
         return -1;

     }
}

```