Question: Why are there two sets of parenthesis here?

```
return state.filter(({ id }) => {
            return id !== action.id    
    });

```

I'm having such a tough time wrapping my head around this one statement! Why can't it just be:

```
return state.filter({ id }) => {
            return id !== action.id
        };

```

Anyone that can even try helping me would be awesome!

Answer: 
You may use

```
\w+(?=\s*=)

```

See the [regex demo](https://regex101.com/r/uaaFid/3)

**Details**

* `\w+` - 1 or more letters, digits or `_` (to only match letters and digits, use `\p{Alnum}`)
* `(?=\s*=)` - that are followed with 0+ whitespaces and then a `=` char (as `(?=...)` is a positive lookahead that requires its pattern to match immediately to the right of the current location).

See the [Java demo](https://ideone.com/bWqU7u):

```
String s = "book = 12 AND x2 = 50";
Pattern pattern = Pattern.compile("\\w+(?=\\s*=)");
Matcher matcher = pattern.matcher(s);
List<String> res = new ArrayList<>();
while (matcher.find()){
    res.add(matcher.group(0)); 
} 
System.out.println(res); 
// => [book, x2]

```
You can capture them all using only one line of code:

```
String [] cols = str.split("\\s*=.*?(?=$|\\w+\\s*=)");

```

Rather than match the column names, this split regex matches *between* the column names.

---

Test code:

```
String str = "book = 12 AND x2 = 50 AND cost = 45";
String[] cols = str.split("\\s*=.*?(?=$|\\w+\\s*=)");
System.out.println(Arrays.toString(cols));

```

Output:

```
[book, x2, cost]

```