Click here to Skip to main content
15,894,017 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
INPUT:
string s="([A-z]{1,})-([a-z]{1,})"


OUTPUT:
should result in an array containing:
([A-z]{1,})
([a-z]{1,})
Posted

 
Share this answer
 
Comments
bala_1990 11-Nov-13 2:35am    
thank you!
Lately, I discovered Named Groups:

C#
string[] result;
string pattern = "((?<FirstGroupName>[A-Za-z]+)-((?<SecondGroupName>[A-Za-z]+))";
Match match = Regex.Match("YourInputString", pattern);
if(match.Success)
{
    result = new string[]{
        match.Groups["FirstGroupName"],
        match.Groups["SecondGroupName"]
    };
}
 
Share this answer
 
v3

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