getting a substring from a given string