I'm trying to get the values of a multi-value node reference and wondered how, or where, the code is that separates the nid within the value.

For example, a value in the field may be: Image 100651 [nid:1255]
So when the form is submitted, I'm looking for the code that splits that apart and gives just the nid value.
I found the preg_match() for the autocomplete, but what about when the form is submitted?