1

I have some string. I need a regex that will replace each occurrence of symbol that is not space + '<' with the same symbol + space + '<'.

In other words if there is '<' without ' ' before it it must add the space.

I've tried something like :

string pattern = "[^ ]<";
string replacement = "$0" + "<";
string result = Regex.Replace(html, pattern, replacement);

Obviously not working as I want.

Tim Schmelter
  • 450,073
  • 74
  • 686
  • 939

1 Answers1

0
   string pattern = "([^ ])<";
   string replacement = "$1" + " <";

You can try something like this.

vks
  • 67,027
  • 10
  • 91
  • 124