dude seems like your requirement is not generalized(specific).
you are filtering the numbers after first whitespace
then in the second string you are taking alphabet 'a' also.
and you are not taking the number after "Yes"
generalize your problem and try to use
regular expression to solve it.