locked
Get string value RRS feed

  • Question

  • User-2132497554 posted

    Hi Folks,

    Here is my string as below:

    var test = "CN=John Smith,OU=ABC,OU=Users,OU=XYZ,DC=ad,DC=My Company,DC=net";

    how to get the value of "John Smith" without condition or may be used regular expression?

    I am waiting for your response.

    Thanks in Advance

    Monday, June 25, 2018 9:12 AM

Answers

  • User1992938117 posted

    Do as below:

    var test = "CN=John Smith,OU=ABC,OU=Users,OU=XYZ,DC=ad,DC=My Company,DC=net";
    		string[] words = test.Split(',');		
    		var result = test.Split(',')[0].Split('=')[1];		
    		Console.WriteLine(result);

    Working Example

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 25, 2018 9:26 AM