AnsweredAssumed Answered

conditional formatting of text between delimiter characters

Question asked by RolfNoyer on Oct 30, 2011
Latest reply on Oct 31, 2011 by philmodjunk

Title

conditional formatting of text between delimiter characters

Post

I want to write a calculation that will take a text, and give me the same text back but with any text appearing between delimiters { and } formatted in italics (later I can strip the delimiter characters).

There may be multiple expressions between { and } in the source text so whatever the calculation is, it has to iterate through the text, i.e. not change just the first string between { and } and also must know to italicize only expressions between { and the very next following }.

It seems like there should be an easy way to do this but I cannot figure it out.

Using suggestions from an earlier forum post, I have this code ("Text" is a variable for the text name):

Substitute
( Text ;
Let ( [var 1 = Position ( Text ; "{" ; 1 ; 1 ) + 1 ;
       var 2 = Position ( Text ; "}" ; 1 ; 1 ) - var 1 ] ;
Middle ( Text ; var 1 ; var 2 ) );
TextStyleAdd (
Let ( [var 1 = Position ( Text ; "{" ; 1 ; 1 ) + 1 ;
       var 2 = Position ( Texts ; "}" ; 1 ; 1 ) - var 1 ] ;
Middle ( Text; var 1 ; var 2 ) ) ; Italic )
)

The problem is that it only italicizes the first string inside the delimiters, leaving the remaining ones untouched. How can I get this to iterate through the text?

Thanks for any advice!

 

Outcomes