using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"set \$(\w+)\s+""?(.+?)""?$";
string substitution = @"\1=""\2""";
string input = @"#========= Variables =========
set $win Mod4
set $alt Mod1
set $ws1 ""1""
set $ws2 ""2""
set $ws3 ""3""
set $ws4 ""4""
set $ws5 ""5""
set $ws6 ""6""
set $ws7 ""7""
set $ws8 ""8""
set $ws9 ""9""
set $ws0 ""0""
set $bar $HOME/.config/polybar/launch.sh
set $locker i3lock -i $HOME/.config/i3/bg.png
set $term kitty
set $menu dmenu -i -l 10
set $browser qutebrowser
set $filemanager kitty -e ranger
set $launcher dmenu_run
set $notify_daemon dunst
set $notify_bar_program xob
set $notify_bar /tmp/xobpipe
set $script $HOME/.config/i3/scripts
set $last_action /tmp/i3/last_action
set $counter /tmp/i3/counter
set $windows /tmp/i3/windows
set $current_workspace i3-msg -t get_workspaces | jq -r '.[] | select(.focused==true).name'
#============================
#======== Autostart =========
exec nm-applet
exec kotatogram-desktop
exec $browser
exec --no-startup-id dunst
#============================";
RegexOptions options = RegexOptions.Multiline;
Regex regex = new Regex(pattern, options);
string result = regex.Replace(input, substitution);
}
}
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