@ olivthill2 , thanks for the tip. strcspn , gave me the correct position of the character. I was not able to include it in the post, but the temporary variable "tmp" was initialized using memset and its size is greater than the actual number of size I extracted from the original string, so I think "tmp" is null terminated. correct me if am wrong.

@aamir121a , thanks for the suggestion. I was actually looking at it too. I am making this program on a busybox so there is very limited libraries and functions available. I am not sure if regular expression included in the platform. I will check.

@GCDEF .. strtok works its wonders again. thanks.

thank you all for the suggestions.