Im refurbishing some old code that used to work on .NET Framework 3.5 to make it work on .NET Framework 4 using C#.
The following Regex used to work fine with version 3.5 but doesn’t work anymore for some strange reason.
public static readonly Regex ChatColorRegex = new Regex("\\|c[A-Za-z0-9]{6,8}"),
ChatLinkRegex = new Regex("\\|H.*?\\|h");
I have added the ‘using System.Text.RegularExpressions’ at the top of my file, but the following error rises: ‘The type or namespace RegularExpressions does not exist in the namespace System.Text.
I’ve googled about that and read that you have to add a Reference to System.Text.RegularExpressions in Visual Studio. However, when i did, i couldn’t find System.Text.RegularExpressions in the list of References i could add.
I’m using Visual Studio 2012.
Could anyone tell me what im doing wrong, or forget to read?
The Regex class is still in the System.Text.RegularExpression namespace. The class is in the System assembly.
If you check your project references in Solution Explorer, you should see a reference to the System assembly. Check the properties of that reference to see what .NET Framework version is being used for the System assembly reference. It should match the .NET Framework version you selected for the “Target framework” in the project properties (Application tab).
Edit: The Regex class is in the System.Text.RegularExpressions namespace, not System.Text.