I'm trying to show formatted label in Xamarin forms (never mind if you are not familiar, the issue is not dependant on this). Given a string which can contain any character and <b></b> tag, I need to create FormattedString object, which contains spans of text. For instance
Lorem ipsum dolor sit amet, consectetur <b>adipiscing elit</b>. Integer imperdiet massa accumsan turpis ullamcorper tempor. <b>Cras eget erat quis mi sollicitudin vehicula.</b> Sed ac risus mattis.
This text should be transformed into these spans
Lorem ipsum dolor sit amet, consectetur
adipiscing elit
. Integer imperdiet massa accumsan turpis ullamcorper tempor.
Cras eget erat quis mi sollicitudin vehicula.
Sed ac risus mattis.
I'm using following regular expression
private static Regex _formatterRegex = new Regex(@"(?<text>[^<>\\/]+)|(?<bold><b>(?<boldBody>[^<>\\/]*)<\\/b>)");
So I match either <b>SOME TEXT</b> or arbitrary text. The problem here is that 'b' of <b></b> tags is also matched. Have a look into matches
I need somehow to match arbitrary text only if it's not inside <b></b> tags, so my match collection will not contain b-s of the html tags. Any ideas?
