Regex Expression Help -Urgent

Hi Team,

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

image

Thanks,
Neelima.

@1996

Check as below

image

Hope this helps you

Follow Link

Thanks

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.

Thanks!

1 Like

Hi @1996,

Can you try this pattern to extract string within Quotes (?<=\“).*(?=\”)

image

Cheers

1 Like

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+

image

3 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.