I am searching for a method to split a character vector based on a RegEx pattern.

Example of input:

```
input <- c("a_foo","b_foo", "c_bar", "d_bar")
split_by <- c("foo", "bar")

```

The result I am searching for:

```
$foo
[1] "a_foo" "b_foo"

$bar
[1] "c_bar" "d_bar"

```

---

**EDIT**

Based on the comments and answers, there is need for a clarification.

1. `split_by` can have any number of elements;
2. the RegEx pattern varies from case to case; and
3. an element in `input` may be assigned to 0 (no matches), 1, or multiple splits depending on the match.

Hence, the following input:

```
input <- c("foo_bar", "nothing", "a_foo", "c_bar")
split_by <- c("foo", "bar")

```

Could return:

```
$foo
[1] "foo_bar" "a_foo"  

$bar
[1] "foo_bar" "c_bar"  

```