I am working on some text processing for location based services where I want to find out if the input matches the type something sth FROM xxxx TO yyyy. Basically I need to find out source and destination that user types.
For example
show me how can I go from xxxx to yyyy
I want to go to abcd
I want to go from abcd to xyz
I am not strong in regex, The regex that I could come up is A-Za-z from A-Za-z to A-Za-z which is not working. Can anyone please tell me how to match multi keyword regex where words may be separated by any number of words. For example I want to go FROM manhattan TO Seattle or I want to go FROM times square, New York City TO Seattle. I can extract source/destination by indexing then.
I am able to extract if it contains FROM in middle of sentence but I want to make it generic so I don’t have to create multiple rules. User may say
I want to go TO x FROM y
I want to go FROM x to Y
In above sentences the source and the destination get swapped.
Thanks
simplest one I can think of would be
.*(from).*(to).*