John.M Posted June 14, 2011 Posted June 14, 2011 Hello, Text parsing is not one of my strong points! I need to be able to take tagged text and convert it to formatted text and there can be 0 to many tags in one line to multiple paragraphs. The tags are <RD>, </RD> for red text, <B>, </B> for bold, and <I>, </I> for Italic. An example may look like: <RD>This text will be red.</RD> The text in this line will be black. <B>The text here is bold</B> and this text is black again, then <I>this text is italicized.</I> Formatted it would look like: This text will be red. The text in this line will be black. The text here is bold and this text is black again, then this text is italicized. Any ideas on how to process this would be greatly appreciated, TIA, John
comment Posted June 14, 2011 Posted June 14, 2011 Try = Let ( [ formula = Substitute ( "" & Quote ( text ) & "" ; [ "<RD>" ; Quote ( " & TextColor ( " ) ] ; [ "</RD>" ; Quote ( " ; 16646400 ) & " ) ] ; [ "<B>" ; Quote ( " & TextStyleAdd ( " ) ] ; [ "</B>" ; Quote ( " ; bold ) & " ) ] ; [ "<I>" ; Quote ( " & TextStyleAdd ( " ) ] ; [ "</I>" ; Quote ( " ; italic ) & " ) ] ) ] ; Evaluate ( formula ) )
John.M Posted June 15, 2011 Author Posted June 15, 2011 This works fantastic, thank you! I was thinking of something far more complex than this! I definitely need to spend time with the "Let" and "Evaluate" functions! Thanks again. John Try = Let ( [ formula = Substitute ( "" & Quote ( text ) & "" ; [ "<RD>" ; Quote ( " & TextColor ( " ) ] ; [ "</RD>" ; Quote ( " ; 16646400 ) & " ) ] ; [ "<B>" ; Quote ( " & TextStyleAdd ( " ) ] ; [ "</B>" ; Quote ( " ; bold ) & " ) ] ; [ "<I>" ; Quote ( " & TextStyleAdd ( " ) ] ; [ "</I>" ; Quote ( " ; italic ) & " ) ] ) ] ; Evaluate ( formula ) )
Recommended Posts
This topic is 4910 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now