Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
Hi guys

I am looking for a regular expression to match:

username='abcdef'

where abcdef can be any amount of numerical or alphabetical characters.

I have tried \\s+username\\s*=\\s* , but it does not match the whole string.

thanks
Posted

MIDL
string input = @"username='abcdef'";
            string regex = @"username='(\w*)'";
            Match m =Regex.Match(input, regex);
            Console.WriteLine(m.Groups[1]);
 
Share this answer
 
Give you the starting point for the expression:

\\busername=["']*\\w["']*\\b

username in this regex consists only from numbers and/or letters. If you want some special characters you have to change it.

Good luck.
 
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