Click here to Skip to main content
15,897,519 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello I am using regex or regular expressions in vb.net and need to learn how to use look ahead to only find the word that comes after a string.

for example

This is the text string: Dog


My problem here is that if i write my regular expression as follows

[This is the text string:] \w+

it will find the string and the word but it will also find other matches of the word dog if they exist. I need to only find the word "Dog" if the string before it is "This is the text string:"

Any help or examples would be greatly appreciated or if anyone can tell me how to find a entire string but exclude everything except the word "dog"

thank you in advance!!
Posted

SQL
I have solved this with look behind like so..

(?<=This is the text string (\w+)
 
Share this answer
 
I have solved this with look behind like so..

(?<=This is the text string:)(\w+)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900