I'm trying to create a Regex expression in vb.net that includes the search term in the result (or have some way of finding which term was found).
For example, with these 2 sentences:
hello Sailor my name is Bill
hello Soldier my name is Bill
I can use this expression to look for either 'Sailor' or 'Soldier':
(?<=Sailor |Soldier ).+?(?= Bill)
... and this gives me:
my name is
Which is the result I want, but I also need to know whether it matched on 'Sailor' or 'Soldier'. Is there a way to do this?
Thanks!