Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
set sample "act-user:IMLI:nmss:1::***; imli 2013-10-21 15:13:54 M 1 COMPLD ; IMLI 2013-10-21 15:13:54 ; >"
如何在 TCL 中使用正则表达式检索 1(从 M 1 COMPLD)这一行???
您需要使用非默认匹配模式(行感知)来使 RE 变得简单:
regexp -line {^M\s+(\d+)\s+COMPLD$} $sample -> value puts "value = $value"
或者,您可以将选项放在 RE 本身中:
regexp {(?n)^M\s+(\d+)\s+COMPLD$} $sample -> value puts "value = $value"
行为完全相同。