文本框标记 获取纯文本有人知道如何获取应用了标记文本的文本框中的纯文本吗?例如,在下面的例子中,我想从文本框中获取文本“这是粗体文本。这是斜体文本。这是下划线文本。这是粗体、斜体、下划线文本。”(不包含标记指令)。
我有一个系统,它会在一些支持标记(主要用于粗体和红色字体)的应用程序底部创建日志,但我希望能够偶尔将日志保存到文件中,并且不包含标记指令。
谢谢!
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 标记获取纯文本真棒的想法!我没有想到使用正则表达式,但这很巧妙。