I have a list of words and I want to match any combination of those words. Assume that I have the words apple
, orange
and mango
and I am working with the following string:
This place has the best apple pie. They also have orange, apple and mango-apple smoothie ...
The regular expression that I have so far is ((apple|orange|mango)[s-(,s)]*)+
It matches the right combination of words but additionally it matches an extra space at the end of the sequence. The matches I get:
"apple "
"orange, apple "
"mango-apple "
I know why it does that. How can I change the regular expression to get rid of that last space at the end?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…