How to extract word from String

I have a RSS feed from the tags i want to extract location using JS from a sentence my approach is to extract the word surrounded by word 'to

Like i have a string: Rideshare is available from London to York. I want to extract London as pickup location and York as dropoff

Will the format always be from X to Y?

Yes BRO!! I got the solution .match(/(\w+)\s+to\s+(\w+)/);

1 Like

THanks though

1 Like