文字方塊標記 取得純文字有人知道如何取得應用了標記文字的文字方塊中的純文字嗎?例如,在下面的例子中,我想從文字方塊中取得文字「這是粗體文字。這是斜體文字。這是下劃線文字。這是粗體、斜體、底線文字。」(不包含標記指令)。
我有一個系統,它會在一些支援標記(主要用於粗體和紅色字體)的應用程式底部建立日誌,但我希望能夠偶爾將日誌保存到文件中,並且不包含標記指令。
謝謝!
Names Default To Here( 1 );
win = New Window( "Example", fontobj = text = Text Box( "Example Text" ) );
text << setText(
"This is <B>bold</B> text. This is <I>italic</I> text. This is <U>underlined</U> text. This is <B><I><U>bold, italic, underlined</U></I></B> text."
);
text << markup;
品質與工藝工程Re: TextBox 標記獲取純文本我只想到了某種正則表達式,但是構建這種模式可能會很煩人
Names Default To Here( 1 );
win = New Window( "Example", fontobj = text = Text Box( "Example Text" ) );
text << setText(
"This is <B>bold</B> text. This is <I>italic</I> text. This is <U>underlined</U> text.
This is <B><I><U>bold, italic, underlined</U></I></B> text.
Text using a <FONT face="Vivaldi">different</FONT> font face.
Text using a <FONT size="16">different</FONT> font size.
This is <FONT color="Blue">blue</FONT> text. This is a <BACKGROUND color="yellow">yellow</BACKGROUND> background. This is <FONT color="#0000ff"><BACKGROUND color="0xffff00">blue text on a yellow background</BACKGROUND></FONT>."
);
text << markup;
Regex(text << get text, "()", "", GLOBALREPLACE);
回复:TextBox 標記獲取純文本真棒的想法!我沒有想到使用正則表達式,但這很巧妙。