使用 Perl Win32::GUI 从文本区域控件获取修剪后的文本
如何从 TextArea 控件中检索修剪后的文本(LTRIM 和 RTRIM)。 TextArea 控件是通过Win32::GUI 模块创建的。
use strict;
use Win32;
use Win32::GUI;
my $DOS = Win32::GUI::GetPerlWindow();
Win32::GUI::Hide($DOS);
my $main_window=Win32::GUI::Window->new(
-name => 'main_window',
-text => 'main_window_Test',
-left => 375,
-top => 200,
-width =>510,#370,
-height =>220,
-background => [190,190,190],
-dialogui => 1,
-maximizebox => 0,
);
my $Entry_Path=$main_window->AddTextfield(
-name => 'entrypath',
-pos => [220,66],
-size => [180,23],
-align => 'left',
-foreground => [],
-tabstop => 1,
);
my $get_trim_Button=$main_window->AddButton(
-text => 'Create Trimmed texts',
-name => 'ncxcreate',
-size => [110,20],
-align=>center,
-pos => [255,150],
-background => [190,190,190],
-foreground => [],
-tabstop => 1,
-disabled=>1
);
$main_window->Show();
Win32::GUI::Dialog();
sub ncxcreate_Click{
my $text_received=$Entry_Path->Text;
}
在上面的代码中,我需要检索 $text_received 标量中的修剪文本值(前导和尾随空格已删除的文本)。
How to retrieve the trimmed text (LTRIM and RTRIM) from a TextArea control.
The TextArea control has been created through Win32::GUI module.
use strict;
use Win32;
use Win32::GUI;
my $DOS = Win32::GUI::GetPerlWindow();
Win32::GUI::Hide($DOS);
my $main_window=Win32::GUI::Window->new(
-name => 'main_window',
-text => 'main_window_Test',
-left => 375,
-top => 200,
-width =>510,#370,
-height =>220,
-background => [190,190,190],
-dialogui => 1,
-maximizebox => 0,
);
my $Entry_Path=$main_window->AddTextfield(
-name => 'entrypath',
-pos => [220,66],
-size => [180,23],
-align => 'left',
-foreground => [],
-tabstop => 1,
);
my $get_trim_Button=$main_window->AddButton(
-text => 'Create Trimmed texts',
-name => 'ncxcreate',
-size => [110,20],
-align=>center,
-pos => [255,150],
-background => [190,190,190],
-foreground => [],
-tabstop => 1,
-disabled=>1
);
$main_window->Show();
Win32::GUI::Dialog();
sub ncxcreate_Click{
my $text_received=$Entry_Path->Text;
}
In the above code I need to retrieve the trimmed text value(leading and trailing spaces removed texts) in the $text_received scalar.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
那么您正在寻找修剪功能吗?
还可以使用 /m 删除每行的前导和尾随空格。
So you're looking for a trim function?
Use /m as well to remove leading and trailing spaces from each line.