find the matched position in a text