Comparison of prefix

how can I compare prefix of two strings?