Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Tcl 多线线头修剪_Tcl - Fatal编程技术网

Tcl 多线线头修剪

Tcl 多线线头修剪,tcl,Tcl,我有一个有多行的问题字符串: line1 Link1: //website/go/<example> line2 它的输出是: found link :<empty line> //website/go/<example> <empty line>` 如何删除所有空格、换行符等,并对其进行修剪,以获得我正在寻找的字符串部分。在这种情况下,只需获取://website/go/ 给定此输入数据: line1 Link1: //websit

我有一个有多行的问题字符串:

line1 
Link1: //website/go/<example> 
line2
它的输出是:

found link :<empty line>
//website/go/<example>
<empty line>`  
如何删除所有空格、换行符等,并对其进行修剪,以获得我正在寻找的字符串部分。在这种情况下,只需获取://website/go/

给定此输入数据:

line1 
Link1: //website/go/<example> 
line2
但是,在这种情况下,我实际上会使用regexp来选择我想要的数据:

regexp -line {Link1:\s+(.*\S)} $output -> temp
puts "found link : $temp

正则表达式往往更适合于解析部分格式的数据,只要您记住保持它们的简短。回复的时间越长,越难理解。

URL是否始终是第二行的第二个字?。是的,它始终是第二行。帖子由my tryPlease update以预期结果进行更新
set temp [string map { " " "" "line1" "" "Link1: " "" "line2" "" } $output]
set temp [string trim $temp]
puts "found link : $temp
regexp -line {Link1:\s+(.*\S)} $output -> temp
puts "found link : $temp