Well, now you have changed the requirements. It would have been better if your original question stated the requirements clearly and completely.
In the s4
example there is a newline \n
character separating the two cases. Is that always true or can s4
be like this?
s4 = "pqr : = 3 aaaa bbb (xyz / cc.dd ee) : = 3456e2";
or
s4 = "pqr : = 3aaaa bbb (xyz / cc.dd ee) : = 3456e2";
Is the number always preceded by : =
or are there other possible character sequences?
If there is always a newline and always preceded by : =
then
(s4 // StringSplit[#, " : = " | "\n"] &)[[2 ;; ;; 2]]
(* {"3", "3456e2"} *)
That will extract the numbers as strings, you can convert to numeric by mapping
Read[StringToStream[#], Number] & /@ {"3", "3456e2"}
(* {3, 345600} *)
s5 = "pqr : = 3
aaaa bbb (xyz / cc.dd ee) : = 3456e2
abc : = 345.6";
(s5 // StringSplit[#, " : = " | "\n"] &)[[2 ;; ;; 2]]
(* {"3", "3456e2", "345.6"} *)