Here is my solution would have to use a string loop through the regex to do the replace as couldn't think of a way to do multiple spaces based on the match.
string html = "erwerw<p style=\"padding-left: 30px;\">ijkk</p>rwwr<p style=\"padding-left: 40px;\">ijkk</p>"; mc = Regex.Matches(html, "(?<complete><p[^>]*style=[^>]*\"[^>]*padding-left:\\s?(?<number>[0-9]*)px[^>]*>(?<text>[^<]*)</p>)"); foreach (Match match in mc) { if (match.Groups.Count > 0) { html = html.Replace(match.Groups["complete"].Value, string.Format("{0}{1}", newstring(' ',Convert.ToInt32(match.Groups["number"].Value)), match.Groups["text"].Value)); } }Hope this helps