Using regex Expression without quotes i am able to get exact word from below line when i tried using within quotes Unable to get exact word. Kindly help me out from this.
How to get word within Quotes
For example:
Please change my password my user name is “Latika” and Let me known.
I tried using below Regex expression check below screenshot.
System.Text.RegularExpressions.Regex.Match(“Please change my password my user name is “Latika” and Let me known.”,“(?<=user name is\W+)\w+”).Value
Thank you for your response above issue got resolved.Kindly help me with another issue, When i am checking with both Keywords User name is and user name with below expression. Instead of latika I am getting the word as is In the both cases i want exact word of Latika
Regex expression:
System.Text.RegularExpressions.Regex.Match(item.ToString,“(?<=user name is\W+|user name\W+)\w+”).Value
For example:
Case 1:
Please change my password my user name “Latika” and Let me known.
Case :2
Please change my password my user name is “Latika” and Let me known.
The reason you get is as match is because the part user name\W+ of your regular expression matches in both cases, but in case 2, the match is is. If you want to exclude is from matching you can add (?!is) to your expression, e.g. (?<=my user name (is)?\W*(?!is))\w+