Question: I have a variable (year) which is all 2007 and 2008s but I need to change it into a factor so it reads 0 and 1s. Is there a way to do this?

So it can be used in a general linear model

Answer: 
This is possible with regexp back references, though not every implementation supports them. Something like:

```
^([^|]+)\|(?:[^|]*\|)*?([^|]*\1[^|]*)

```

Second group will capture what you need.

Explanation: `^([^|]+)\|` captures your keyword, `(?:[^|]*\|)*?` matches zero or more strings surrounded by `'|'` not having keyword, `([^|]*\1[^|]*)` matches what you finally need.

[Demo](https://regex101.com/r/Td8Adq/1)
Here is a pattern which seems to be working:

```
(?<=\||^)((?:(?!\|).)*Interface123.*?)(?=\||$)

```

This uses tempered dots to match the segment of the string you want, containing `Interface123`. Here is a brief explanation:

```
(?<=\||^)       assert that what is prior is either pipe or the start of the string
((?:(?!\|).)*   consume anything so long is it is NOT pipe
Interface123.*? match 'Interface123` followed by anything up to
(?=\||$)        assert that what follows is either pipe or the end of the string

```

[Demo
----](https://regex101.com/r/nK4Sos/1)

This answer uses lookarounds, but based on your comment that your regex flavor is Perl compatible, this should not be a problem.