The space character is the character immediately after the last hyphen in the text.
Suppose the text were just: "a - b".
The length of this text is is 5, and the position of the hyphen is 3.
5 - 3 = 2, so your expression:
Right ( db ; len - lastSpace )
will return the last two characters of the text, i.e. " b".
It depends. If the hyphen separator is always followed by a space, you might simply subtract it:
Right ( db ; len - lastSpace - 1 )
A better solution would look for the position of the entire separator pattern " - " (a hyphen surrounded by spaces) and do:
Let ( [
len = Length ( db ) ;
lastSeparator = Position ( db ; " - " ; len ; -1 )
] ;
Right ( db ; len - lastSeparator - 2 )
)
This would allow you to correctly extract "Carter-Brown" from "Smith - Jones - Carter-Brown".
If you cannot be sure the space/s will always be there, you may use Trim() on the result (this is assuming the extracted portion will not contain any significant whitespace characters).