Reputation: 2385
I have some text that i get returned from a method in the format like this Title B-17G Flying Fortress Country United States of America Rank 4 Rating 6 Max altitude 11156 m Max speed 510.12 km/h on altitude 7680 m Turn time 36 s Take on distance 600 m Climb time 1680 s to altitude 7620 m Climb rate 4.5 m/s Time for free repair 108 h 16 m Max repair cost 6140 s.l. Cost 210000 s.l.
.
So basically, from the above, I need to extract "B17G Flying Fortress", "United States of America", "4", "6", " 11156 m", "510.12 km/h on altitude 7620 m", etc..
I've been trying to come up with a proper regex but havent yet. Ideas?
Upvotes: 0
Views: 53
Reputation: 420
If it is one long string, and the labels remain constant, you could use a regex like (?=Title)(.*?)(?=Country)
Upvotes: 1
Reputation: 4201
Is this decision fix your problem?
"Title B-17G Flying Fortress Country United States".replace(/^(\s*[^\s]+)/,"$1 : ");
Best regards
Upvotes: 1