In the string the username is probably preceded with fixed set of characters and followed with a fixed number of characters. Use
findAll('precedingtext', $YourVariableIncludingTheUsername)
and
findAll('followingtext', $YourVariableIncludingTheUsername)
to get the first and last position of the username. Then use
substring($YourVariableIncludingTheUsername, $PositionFirstCharacter, $PositionLastCharacter)