dimanche 15 février 2015

regex for pattern before a certain word

I am having problems finding a right RegEx for recognizing the word before a certain word (but without the latter word). Below is the pattern, where W1 is dynamically asigned word.



Set regExp = New RegExp
With regExp
.Pattern = "\S* " + W1
.IgnoreCase = True
.Global = True


This pattern works but i get the whole pattern. If I have such sentence :"Today is a sunny day" and W1 is set as "day", this pattern gives me "sunny day".


I would like to get just sunny, without the W1. Is this possible?


Thanks,m


Aucun commentaire:

Enregistrer un commentaire