- 浏览: 318011 次
最新评论
-
riki:
D 语言学习交流群 264617728, 欢迎加入
D语言真相 The Case for D(1-5) -
exploder:
请教,如果使用D2进行wxD编译呢?
编译WxD0.16 -
blue_halo:
那如何解决呢????????
不能每次都用别的打开存成utf- ...
pyDev 中输入中文问题 -
funxue:
请教楼主
Error: undefined identifie ...
D语言版本的华容道 -
litsen:
在配置ms sqlserver的过程中遇到些问题,从Googl ...
安全第一,在sql server和client之间配置ssl连接
部分内容来自wiki4D.
module regexp; import std.stdio : writefln; import std.regexp; import std.c.stdio; bool isalpha(char[] c) { RegExp myRegExp; myRegExp = new RegExp("^[a-zA-Z_]+$", ""); return cast(bool) myRegExp.test(c); } bool isspace(char[] c) { /* true if c is whitespace, false otherwise */ RegExp myRegExp = new RegExp("^\\s+$", ""); return cast(bool) myRegExp.test(c); } bool isdigit(char[] c) /* true if c is a decimal digit, false otherwise */ { RegExp myRegExp = new RegExp("^\\d+$", ""); return cast(bool) myRegExp.test(c); } bool ishexdigit(char[] c) /* true if c is a hexadecimal digit, false otherwise */ { RegExp myRegExp = new RegExp("^[0-9A-F]+$", ""); /* If it were D code, "_" would also be valid */ return cast(bit) myRegExp.test(c); } bool isoctdigit(char[] c) /* true if c is an octal digit, false otherwise */ { RegExp myRegExp = new RegExp("^[0-7]+$", ""); return cast(bool) myRegExp.test(c); } bool issymbol(char[] c) /* true if c is legal SQL symbol, false otherwise */ { RegExp myRegExp = new RegExp("^[\\(\\)\\[\\]\\.,;=<>\\+\\-\\*/&\\^]+$", ""); return cast(bool) myRegExp.test(c); } bool isDate(char[] c) /* true if c is a date, false otherwise */ { RegExp myRegExp = new RegExp("((((19){1}|(20){1})d{2})|d{2})[01]{1}d{1}[0-3]{1}d{1}", ""); //1900 return cast(bool) myRegExp.test(c); } bool isChinese(char[] c) /* true if c is a chinese string, false otherwise */ { RegExp myRegExp = new RegExp("^[\u4e00-\u9fa5]+$", ""); return cast(bool) myRegExp.test(c); } bool iscnPhone(char[] c) /* true if c is a china phone code, false otherwise */ { RegExp myRegExp = new RegExp("\\d{3}-\\d{8}|\\d{4}-\\d{7}", "g"); return cast(bool) myRegExp.test(c); } bool iscnMobile(char[] c) /* true if c is a china Mobile code, false otherwise */ { RegExp myRegExp = new RegExp("^((\\(\\d{2,3}\\))|(\\d{3}\\-))?13\\d{9}$", ""); return cast(bool) myRegExp.test(c); } bool iscnZip(char[] c) /* true if c is a china ZIP, false otherwise */ { RegExp myRegExp = new RegExp("^[0-9]\\d{5}$", ""); return cast(bool) myRegExp.test(c); } bool iscnIDcard(char[] c) /* true if c is a china ID card, false otherwise */ { RegExp myRegExp = new RegExp("\\d{15}|\\d{18}", ""); return cast(bool) myRegExp.test(c); } unittest { /* compile with the -unittest flag to run these tests */ writefln("Testing functions..."); assert(isalpha("a") && isalpha("A") && !isalpha("9") && isalpha("_") && isalpha("R") && !isalpha("&")); assert(issymbol("(") && issymbol(")") && issymbol("[") && issymbol("]") && issymbol(")") && issymbol("[") && issymbol("]") && issymbol("-") && issymbol("/") && issymbol("=") && issymbol("*") && issymbol(".") && !issymbol("a") && !issymbol("0") && !issymbol("Y") && !issymbol("\\")); assert(isdigit("0") && isdigit("7") && isdigit("9") && !isdigit("A") && !isdigit("^") && !isdigit("G")); assert(ishexdigit("0") && ishexdigit("7") && ishexdigit("A") && !ishexdigit("^") && !ishexdigit("G")); assert(isoctdigit("0") && isoctdigit("7") && !isoctdigit("8") && !isoctdigit("A") && !isoctdigit("^")); assert(isspace(" ") && isspace("\t") && !isspace("o") && !isspace(".") && !isspace("5")); assert(isChinese("中文") && isChinese("哦") && !isChinese("*.") && !isChinese("abcd") && !isChinese("5")); assert(iscnPhone("010-12345678") && iscnPhone("0710-1234567") && !iscnPhone("01-12345") && !iscnPhone("010-12") && !iscnPhone("0314-123456") && iscnPhone("0314-12345678-90")&& iscnPhone("0314-12345678-901") && iscnPhone("012345-12345678-901") ); assert(iscnMobile("13123456789")&& !iscnMobile("139123456789") && !iscnMobile("*.") && !iscnMobile("abcd") && !iscnMobile("5") ); assert(iscnZip("100081")&& iscnZip("012346") && !iscnZip("*.") && !iscnZip("abcd") && !iscnZip("5") ); writefln("Functions tested successfully."); } void main() { /* Compile with the -debug flag for this statement to run. */ debug writefln("Main Program."); }
发表评论
-
最近抽空翻译了D语言实用入门教程
2018-04-20 10:42 812最近抽空翻译了D语言实用入门教程 地址在Github,供初 ... -
编译WxD0.16
2011-09-27 18:09 1640wx我在Python环境下用了 ... -
简单看了下DGui
2011-09-26 10:39 2173很久没有写代码了。。。。 怀念往日不如今天行动。生疏了 ... -
支持中文录入的harmonia
2010-08-16 22:40 988harmonia界面很方便,发现不能录入中文.Patch一下. ... -
控制台得到密码不回显
2009-09-18 22:37 1208看到坛子有人问“在D或C下如何实现输入单个字符不回显?可能的应 ... -
D资源文件调用
2009-08-09 01:36 1012终于成功了。 资源文件太可爱,竟然可以如此。按名称进行 ... -
The Case for D中英文版PDF下载
2009-06-19 10:27 1348The Case for D 在网站上浏览不方便的,有了PD ... -
D语言真相 The Case for D(1-5)
2009-06-17 09:52 4751D语言真相 Andrei Alexandre ... -
The Case for D
2009-06-16 22:50 2269The Case for D Andrei Alexan ... -
Python嵌入D
2009-06-12 11:37 1862所有的嵌入都研究了一个遍。发现嵌入Python挺好,试试。 ... -
实用的DFL注册表
2009-05-27 09:09 942应用中要用到注册表.DFL里面有. 参照了文档,写了一 ... -
DFL 2.027,1.041,2,3编译
2009-04-07 17:59 1539注:DFL已经更新,http://www.dprogrammi ... -
D2.0的字符串
2009-04-07 08:28 1339D2.0的字符串增加了常量,不变量和变量.在很大程度上增加了语 ... -
D语言编译器DMD开源了!
2009-03-05 19:56 3401自从1999年12月,Walter设计开发D语言以来,D语 ... -
D语言现状From2007
2009-03-02 15:32 995I'm sure this was brought up in ... -
D语言GUI库简单比较
2009-02-20 15:25 3163通过对一些D语言可以使用的GUI进行比较,对初学者有个借 ... -
D语言脚本引擎简单比较
2009-02-19 14:38 1766经过长期的测试,使用,扩展代码编写,比较了D中可以使用的几种脚 ... -
D语言编译器开始支持Mac OSX
2009-02-15 18:25 1085D语言编译器开始支持Mac OSX。 D语言历经10年的发 ... -
触发DFL中的ComboBox控件的键盘事件
2009-02-06 12:04 1140class ComboxKeyDownFilter:IMess ... -
DFL分析(四)伟大的结构
2008-12-25 00:08 1380每个程序都有很多的代码编织而成.为了获得最大的兼容性,你要从容 ...
相关推荐
JavaScript采用的是Perl语言正则表达式语法的一个相当完整的子集. 正则表达式的模式规范是由一系列字符构成的.大多数字符(包括所有字母数字字符)描述的都是按照字面意思进行匹配的字符.这样说来,正则表达式/java/...
学习正则表达式的最好方法是从例子开始,理解例子之后再自己对例子进行修改,实验。下面给出了不少简单的例子,并对它们作了详细的说明。 假设你在一篇英文小说里查找hi,你可以使用正则表达式hi。 这几乎是最简单的...
什么是正则表达式呢? 正则表达式(regular expression)描述了一种字符串匹配的模式,可以用来检查一个字符串是否含有某种子串、将匹配的子串做替换或者从某个字符串中取出符合某个条件的子串等。 先科普一下基本的...
本文所举例子是在《JavaScript语言精粹》上看到的,看完之后对正则表达式有了进一步的理解,故分享之。 例子 //这是一个用来匹配URL的正则表达式,分组获取不同部分的信息 var parse_url = /^(?:([A-Za-z]+):)?(\/...
正则表达式是一种用来匹配字符串的强有力的武器,它用一种描述性的语言来给字符串定义一个规则,凡是符合规则的字符串,我们就认为它“匹配”了,否则,该字符串就是不合法的。 用\d可以匹配一个数字,\w可以匹配一...
* Summary of regular-expression constructs 正则表达式结构简介: * Construct Matches * Characters 字符: * x The character x x 字符 x * \\ The ...
正则表达式学习请打开文件夹里的“Microsoft Windows 脚本技术.chm”,依次展开树“Windows 脚本技术 - VBScript - 正则表达式简介”,认真学习吧,需要耐心和不停的试验,学好了绝对是一把利器。我以前学习都要写vb...
此外,JavaScript这种客户端的脚本语言也提供了对正则表达式的支持,现在正则表达式已经成为了一个通用的概念和工具,被各类技术人员所广泛使用。 在某个Linux网站上面有这样的话:"如果你问一下Linux爱好者最喜欢...
作者从语法、对象、函数、继承、数组、正则表达式、方法、样式和优美的特性这9 个方面来呈现这门语言真正的精华部分,通过它们完全可以构建出优雅高效的代码。作者还通过附录列出了这门语言的毒瘤和糟粕部分,且告诉...
从正则表达式处理到格式化报表,从数据库到进程间通信以及Web开发。它教大学Perl,同时教了大家许多Unix和Windows知识。设计网络、系统调用、IPC和CGI这些主题可以节省了解函数作用、所需要的库以及正确语法的时间。...
前言 第1章 精华 ...第7章 正则表达式 7.1 一个例子 7.2 结构 7.3 元素 第8章 方法 第9章 代码风格 第10章 优美的特性 附录A:糟粕 附录B:鸡肋 附录C:JSLint 附录D:语法图 附录E:JSON 索引
从正则表达式构建FA 在确定NFA的同时改善对新州的管理 安装 目前尚无车轮包装。 您可以使用setuptools从github直接安装它。 pip install git+https://github.com/pjdevs/pyautomata 例子 a = NFAutomaton ( set ( ...
Javascript小技巧一箩筐 ...语言设置 onclick="window.external.ShowBrowserUI("LanguageDialog", null)"> 加入收藏夹 onclick="window.external.AddFavorite("http://www.google.com/", "google...
9.1 正则表达式定义 129 9.1.1 方括号表达式 130 9.1.2 转义字符 130 9.2 POSIX风格的函数 131 9.2.1 ereg 和eregi 131 9.2.2 ereg_replace 和eregi_replace 132 9.2.3 Split 133 9.3 PERL风格函数 134 9.3.1 模式定...
9.6.2 /etc/rc.d httpd脚本 168 9.7 配置文件清单 170 9.8 小结 185 第10章 Internet新闻 186 10.1 Linux与新闻组 186 10.1.1 新闻供给点如何工作 187 10.1.2 推/拉新闻 187 10.1.3 下载新闻组的可选方法 187 10.2 ...
\13.5.1 基本的正则表达式 342 \13.5.2 文字捕获 344 \13.6 小结 345 \高 级 篇 \第14章 XML 348 \14.1 DOM 348 \14.1.1 DOM入门 348 \14.1.2 使用DOM 348 \14.1.3 使用DOM写XML文件 352 \14.2 SAX 354 \...
\13.5.1 基本的正则表达式 342 \13.5.2 文字捕获 344 \13.6 小结 345 \高 级 篇 \第14章 XML 348 \14.1 DOM 348 \14.1.1 DOM入门 348 \14.1.2 使用DOM 348 \14.1.3 使用DOM写XML文件 352 \14.2 SAX 354 \14.3 基于流...