tcl-regular expression-practice
来源:互联网 发布:网站建设以及seo 编辑:程序博客网 时间:2024/05/21 06:28
% set text "Some arbitrary text which might include \$ or {"
Some arbitrary text which might include $ or {
% regexp -inline -all -- {\S+} $text
Some arbitrary text which might include {$} or \{
% set str 66.70.7.154
66.70.7.154
% regexp "(\[0-9]{1,3})\.(\[0-9]{1,3})\.(\[0-9]{1,3})\.(\[0-9]{1,3})" $str all f
irst second third fourth
1
% puts "$all \n $first \n $second \n $third \n $fourth \n"
66.70.7.154
66
70
7
154
% puts "$all\n$first\n$second\n$third\n$fourth\n"
66.70.7.154
66
70
7
154
% set string "0377.255.255.255"
0377.255.255.255
% regexp {^\d+\.\d+\.\d+\.\d+$} $string
1
% regexp {^\d+\.\d+\.\d+\.\d+$} $string a b c d
1
% puts "$a,$b,$c,$d"
0377.255.255.255,,,
% puts "$a"
0377.255.255.255
% set word "foo"
foo
% regexp {(foo|bar)} match zzz
0
% regexp {(foo|bar)} match foo
0
% regexp {(foo|bar)} foo
1
% set word "foo"
foo
% set result [regexp {(foo|bar)} $word match zzz]
1
% set match
foo
% set zzz
foo
% set result [regexp {(foo|bar)} $word match]
1
% set match
foo
% set str " sjkhf sdhj "
sjkhf sdhj
% regexp {^ +.* +$} $str match
1
% set match
sjkhf sdhj
% set rest [regexp {^ +.* +$} $str match]
1
1
% regexp {abc$} dabcd
0
% regexp {\d} dabcd
0
% regexp {\d} 123
1
% regexp {\d} "123 abc"
1
% regexp {\d} "123 abc" num
1
% set num
1
% regexp {\d} "323 abc" num
1
% set num
3
% regexp {\d+} "123 abc" num
1
% set num
123
% regexp {\d+} "323d 33 abc" num
1
% set num
323
% regexp {\w+} "123 abc" num
1
% set num
123
% regexp {\w+} "a1234 abc" num
1
% set num
a1234
%
- tcl-regular expression-practice
- Best game to practice regular expression with fun
- regular expression
- Regular Expression
- regular expression
- Regular Expression
- Regular Expression
- regular expression
- Regular Expression
- Regular Expression
- regular expression
- Regular expression
- Regular Expression
- Regular Expression
- regular expression
- Regular expression
- regular expression
- regular expression
- 史密斯夫妇握手问题
- GridView和DataSource的联合使用
- 在gerrit的git仓库中将仓库的所有版本提交到远程github仓库中
- 临界区重叠:移出临界区+shared_ptr写时拷贝
- android游戏开发入门: 贪吃蛇 源代码分析
- tcl-regular expression-practice
- 黑马程序员----java面向对象03(接口、多态)
- 用NSTask执行外部命令并获取输出结果的方法
- foobar的cue生成插件
- dhtmlxGrid分页查询,条件查询实例
- 【OpenCV入门指南】第一篇 安装OpenCV
- 扩展jquery实现客户端表格的分页、排序
- Flex报错归类(三)
- Nodejs获取本机地址