Click here to Skip to main content
14,327,607 members
Rate this:
Please Sign up or sign in to vote.
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
Rate this:
Please Sign up or sign in to vote.

Solution 1

string input = @"username='abcdef'";
            string regex = @"username='(\w*)'";
            Match m =Regex.Match(input, regex);
            Console.WriteLine(m.Groups[1]);
   
Rate this:
Please Sign up or sign in to vote.

Solution 2

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.
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100