I am trying to work out a regex that can split an OU path into is sub parts so I can create a comple path one OU at a time. (The bit I am worry about here is just how to split the path with regex).
OUPath = "LDAP://OU=Test2,oU=Test1,
What I would like to be able to do is change the code below
So it can split it like the following:
I will also accept the output being
The main point is each OU is matched and the OU is not case sensitive. So all the following will match.
Ou=, OU=, oU=, ou=
So I know the code below does not work - wanted to change it so I can make it work.
I am looking for the modifcations required to make it work the way I want.
static void Main(string args)
OUPath = "LDAP://OU=Test2,oU=Test1,ou=LoadTestOU,DC=acme,DC=local";
Regex ex = new Regex("OU=(*?),",RegexOptions.IgnoreCase);
MatchCollection col = ex.Matches(OUPath);
List<String> values = new List<string>();
foreach (Match matchItem in col)