Quantcast
Channel: How to split this string to obtain just the name value - Stack Overflow
Browsing latest articles
Browse All 5 View Live

Answer by Grant Winney for How to split this string to obtain just the name...

Another option, using LINQ.If the name/value pair exists anywhere in the string, you'll get it; if not, managerName will be null.var managerName = input.Split(',') .Where(x => x.StartsWith("CN="))...

View Article



Answer by dav_i for How to split this string to obtain just the name value

I find doing it like this fairly easy to read:var input = @"CN=Andrew Adams,OU=Services,OU=Users,OU=GIE,OU=CSP,OU=STAFF,DC=example,DC=net";var items = input.Split(',');var keyValues = items.Select(x...

View Article

Answer by Bobson for How to split this string to obtain just the name value

This is a great place to use Regular Expressions. Try this:var text = "CN=Andrew Adams,OU=Services,OU=Users,OU=GIE,OU=CSP,OU=STAFF,DC=example,DC=net";var match = Regex.Match(text, @"CN=([^,]+)");if...

View Article

Answer by Amit Joki for How to split this string to obtain just the name value

You can do this:var name = "CN=Andrew Adams,OU=Services,OU=Users,OU=GIE,OU=CSP,OU=STAFF,DC=example,DC=net".Split(',')[0].Split('=')[1];DemoWhat it does is splits on , and takes the first element and...

View Article

How to split this string to obtain just the name value

Hi I am looking for a simple way to et just the name after the CN value CN=Andrew Adams,OU=Services,OU=Users,OU=GIE,OU=CSP,OU=STAFF,DC=example,DC=netis there an easy way to do this? I am currently...

View Article

Browsing latest articles
Browse All 5 View Live




Latest Images