tags:

views:

222

answers:

1

I have string like \LESSING\root\cimv2:Win32_UserAccount.Domain="LESSING",Name="Admin" How to convert it to LESSING\Admin using Framework?

+4  A: 

If your are sure of the syntax, maybe a regex... although regex is often overused, it seems to fit this time:

string input = @"\LESSING\root\cimv2:Win32_UserAccount.Domain=""LESSING"",Name=""Admin""";
string output = Regex.Replace(input, @"^.*Domain=""([^""]*)"",Name=""([^""]*)"".*$", @"$1\$2");
Marc Gravell
It really works!!! THANK YOU!!!
Juri Bogdanov