⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ex9.tcl

📁 很不错的tcl编程实例
💻 TCL
字号:
# Copyright 1996


# Authors

# Lakshmi Sastry
# Computing and Information Systems Department
# Rutherford Appleton Laboratory, Chilton, Didcot. OX11 0QX
# lakshmi.sastry@rl.ac.uk

#                         and

# Venkat VSS Sastry
# Department of Applied Mathematics and Operational Research
# Cranfield University, RMCS Shrivenham, Swindon, SN6 8LA
# sastry@rmcs.cran.ac.uk

# Permission to use, copy, modify, and distribute this
# software and its documentation for any purpose and without
# fee is hereby granted, provided that this copyright
# notice appears in all copies.
  
# The authors, RAL, RMCS Shrivenham, Cranfield University and AGOCG
# make no representations about the suitability of this
# software for any purpose.  It is provided "as is" without
# express or implied warranty. Likewise they accept no responsibility
# whatsoever for any public domain software modules used (which are
# hereby acknowledged) in this software 


# regexp_ex1.tcl - simple usage
#
set s1 {Travel Costs: 346.85}
puts $tout "$s1\n"
#
# match any positive numbers with a decimal point
#    curly braces are necessary to define the pattern to protect from 
#    command substitution
#    matched pattern is stored in the variable "match"
#
regexp {[1-9]+\.[1-9]+} $s1 match
puts $tout "$match\n"

#
set s2 {5 green bottles sitting on the wall, if 1 green bottle ..., 4 green}
puts $tout "$s2\n"
#
# to match any positive number followed by zero or more spaces, followed by
#    one or more characters in the range a-z
#    x contains "5 green",
#    y contains 5,
#    z contains green
regexp {([0-9]+) *([a-z]+)} $s2 x y z

puts $tout "x is $x \n"
puts $tout "y is $y \n"
puts $tout "z is $z \n"

# pattern to pick words following the descriptor, Keywords: , at the beginning
# of the line. 
#  a contains "Keywords: source, expr, set"
#  b contains "Keywords:"
#  c contains "source, expr, set"
#
regexp {(^ *[Kk]eywords:) *([a-z, ]+)} "Keywords: source, expr, set" a b c
puts $tout "a is $a \n"
puts $tout "b is $b \n"
puts $tout "c is $c \n"

regexp {(^ *[Kk]eywords:) *([a-z, ]+)} "  keywords: expect send button" a b c

puts $tout "a is $a \n"
puts $tout "b is $b \n"
puts $tout "c is $c \n"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -