Like this:

=LEFT(A1,5)=LEFT(B1,5) will return TRUE if the first 5 characters match and FALSE if they don't