using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(?(?=The following software are installed on the remote host :\s+))(?<software>[^\[]+)\[version\s(?<version>[^\]]+)\]";
string input = @"""20811"","","",""None"",""182.56.44.12"",""tcp"",""445"",""Microsoft Windows Installed Software Enumeration (credentialed check)"",""It is possible to enumerate installed software."",""This plugin lists software potentially installed on the remote host by
crawling the registry entries in :
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
HKLM\SOFTWARE\Microsoft\Updates
Note that these entries do not necessarily mean the applications are
actually installed on the remote host - they may have been left behind
by uninstallers, or the associated files may have been manually
removed."",""Remove any applications that are not compliant with your organization's
acceptable use and security policies."","",""
The following software are installed on the remote host :
7-Zip 15.12 (x64) [version 15.12]
Rapid Recovery Agent [version 6.1.3.100]
JXplorer [version 3.3.1]
System Center Endpoint Protection [version 4.10.207.0] [installed on 2016/10/26]
Notepad++ [version 6.8.8]
WinPcap 4.1.3 [version 4.1.0.2980]
Wireshark 2.2.4 (64-bit) [version 2.2.4]
Windows Firewall Configuration Provider [version 1.2.3412.0] [installed on 2015/11/20]
Microsoft Visual C++ 2013 x86 Minimum Runtime - 12.0.21005 [version 12.0.21005] [installed on 2015/11/20]
Microsoft Visual C++ 2010 x64 Redistributable - 10.0.40219 [version 10.0.40219] [installed on 2015/12/17]
Microsoft Visual C++ 2013 x64 Additional Runtime - 12.0.40649 [version 12.0.40649] [installed on 2017/01/26]
Java 7 Update 79 (64-bit) [version 7.0.790] [installed on 2015/12/14]
Configuration Manager Client [version 5.00.8239.1000] [installed on 2018/03/28]
Microsoft Visual C++ 2013 Redistributable (x64) - 12.0.40649 [version 12.0.40649.5]
Microsoft Endpoint Protection Management Components [version 4.10.0207.0] [installed on 2016/10/26]
Java SE Development Kit 7 Update 79 (64-bit) [version 1.7.0.790] [installed on 2015/12/14]
Microsoft Visual C++ 2005 Redistributable [version 8.0.61001] [installed on 2015/12/17]
Microsoft Visual C++ 2013 Redistributable (x64) - 12.0.21005 [version 12.0.21005.1]
AppRecovery Agent [version 6.1.3.100] [installed on 2018/03/18]
Microsoft Silverlight [version 5.1.30514.0] [installed on 2015/11/20]
Microsoft Policy Platform [version 1.2.3602.0] [installed on 2015/11/20]
Microsoft Forefront Endpoint Protection 2010 Server Management [version 4.10.0207.0] [installed on 2016/10/26]
Microsoft Visual C++ 2013 x64 Minimum Runtime - 12.0.40649 [version 12.0.40649] [installed on 2017/01/26]
Microsoft Security Client [version 4.10.0207.0] [installed on 2016/10/26]
Microsoft SQL Server System CLR Types (x64) [version 10.51.2500.0] [installed on 2015/12/17]
Microsoft SQL Server 2008 R2 Management Objects (x64) [version 10.51.2500.0] [installed on 2015/12/17]
Microsoft Visual C++ 2010 x86 Redistributable - 10.0.40219 [version 10.0.40219] [installed on 2015/12/17]
Microsoft Visual C++ 2013 x86 Additional Runtime - 12.0.21005 [version 12.0.21005] [installed on 2015/11/20]
Microsoft Visual C++ 2005 Redistributable (x64) [version 8.0.61000] [installed on 2015/11/20]
Microsoft Visual C++ 2013 Redistributable (x86) - 12.0.21005 [version 12.0.21005.1]
""";
foreach (Match m in Regex.Matches(input, pattern))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx