TheUninvited
Active Coder
So basically i've been trying to convert sublime snippets to visual studio. So far i created this to grab all the snippets inside the sublime text and i am wondering if there's any way to improve the way of finding the elements in the for loop? My code works you know but to me i am trying to make this converter for training and learning purposes i know there is a snippet designer out there i can probably just do everything with my hands and i can still be fine it would take less time than trying to copy and paste my snippets from sublime. But still i just thought why not do this
Here is the code and video :
The code:
The video:
The code:
C#:
public void regexReplaceSublimeParameters(int num, List<string> mylist)
{
Regex maxReg = new Regex(@"(\${)" + num + @"(.*?)(?=})");
Match maxMatch = maxReg.Match(subInText);
for (int i = 0; i < ReturnCounter(); i++)
{
if (maxMatch.Success)
{
maxReg = new Regex(@"(\${)" + num + @"(.*?)(?=})");
maxMatch = maxReg.Match(subInText);
mylist.Add(maxMatch.Value);
num++;
}
}
foreach (string list in mylist)
{
Console.WriteLine(list);
}
}
public int ReturnCounter()
{
Regex maxReg = new Regex(@"(\${)" + counter + @"(.*?)(?=})");
Match maxMatch = maxReg.Match(subInText);
while (maxMatch.Success)
{
if (!maxMatch.Success)
{
break;
}
else
{
counter++;
maxReg = new Regex(@"(\${)" + counter + @"(.*?)(?=})");
maxMatch = maxReg.Match(subInText);
}
}
return counter;
}
The video:
Last edited by a moderator: