S
Stephan Bour
I have a string ³Name² in the following format: ³LastName, FirstName
(Department)² that comes from Active Directory. I need to extract the
FirstName from the string. Substrings are not practical for this so I used a
Regex that splits the string at the first ³, ³ and again at the ³ (³. My
problem is that I don¹t know how to extract the second member of the
resulting array (FirstName) and assign it to another string. Using
StringBuilder, as below returns a single string with all the matches
concatenated. Any idea?
Thanks,
Stephan.
public String FirstName {
get {
Regex SplitName = new Regex(" (|, ");
StringBuilder sBuilder = new StringBuilder();
foreach (string Found in SplitName.Split(Name) {
mFirstName = sBuilder.AppendFormat(Found).ToString();
return mFirstName;
}
}
}
(Department)² that comes from Active Directory. I need to extract the
FirstName from the string. Substrings are not practical for this so I used a
Regex that splits the string at the first ³, ³ and again at the ³ (³. My
problem is that I don¹t know how to extract the second member of the
resulting array (FirstName) and assign it to another string. Using
StringBuilder, as below returns a single string with all the matches
concatenated. Any idea?
Thanks,
Stephan.
public String FirstName {
get {
Regex SplitName = new Regex(" (|, ");
StringBuilder sBuilder = new StringBuilder();
foreach (string Found in SplitName.Split(Name) {
mFirstName = sBuilder.AppendFormat(Found).ToString();
return mFirstName;
}
}
}