I know how to use Regex.Split() and Regex.Replace(); but not how to keep certain data when replacing.
if I had the following lines of text in a String[] (Split after every 😉
“
using system;
using system.blab;
using system.blab.blabity;
“
how would I loop trough and replace all ‘using’ to ” but match the whole line ‘using (.+;)’ for example.
and end up with the following (but not just Regex.replace(“using”, “”);)
“
<using> system;
<using> system.blab;
<using> system.blab.blabity;
“
This should get you pretty close. You should use a named group for every logical item you’re trying to match. In this instance, you’re trying to match everything that is not the string “using”. You can then use the notation ${yourGroupName} to reference the match in the replacement string. I wrote a tool called RegexPixie that will show you live matching of your content as you type so you can see what works and what doesn’t work.