Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- This would be *italicized* text and this would be **bold** text
- This would be <em>italicized</em> text and this would be <strong>bold</strong> text
- private string DoItalicsAndBold (string text)
- {
- // <strong> must go first:
- text = Regex.Replace (text, @"(**|__) (?=S) (.+?[*_]*) (?<=S) 1",
- new MatchEvaluator (BoldEvaluator),
- RegexOptions.IgnorePatternWhitespace | RegexOptions.Singleline);
- // Then <em>:
- text = Regex.Replace (text, @"(*|_) (?=S) (.+?) (?<=S) 1",
- new MatchEvaluator (ItalicsEvaluator),
- RegexOptions.IgnorePatternWhitespace | RegexOptions.Singleline);
- return text;
- }
- private string ItalicsEvaluator (Match match)
- {
- return string.Format ("<em>{0}</em>", match.Groups[2].Value);
- }
- private string BoldEvaluator (Match match)
- {
- return string.Format ("<strong>{0}</strong>", match.Groups[2].Value);
- }
Add Comment
Please, Sign In to add comment