I have several classes that I need to format. I need to place the using directives inside the namespace. In other words I have to change:
// some comment about system
using System;
using System.Collections.Generics; // needed to create lists
namespace MyNamespace
{
... code
into:
namespace MyNamespace
{
// some comment about system
using System;
using System.Collections.Generics; // needed to create lists
... code
So in short I will like to be able to match:
// some comment about system
using System;
using System.Collections.Generics; // needed to create lists
what I have worked so far is this regex: (?s)(//.*?(?=\r))(\r\n|^)*using .*?;
the first group (//.*?(?=\r))(\r\n|^) matches a comment. so if the using has a comment I will like to take that comment also. Note that I placed a * at the end of the group in order to have 0 or more comments. for some reason the second using is not matched why?
IF you where to have something like:
the regex:
would match the all the using statements.