- 浏览: 12351 次
最新评论
/* 最近简单看了下ATL中的正则表达式,感觉不好用,主要是她的正则表达式规则太简单,有些情况匹配不出来,当然也许是我自己对正则表达式都不是很熟练,所以写不出匹配的规则,不过还是要记录下他的使用方法 */ CAtlRegExp regexp; //这里模板中不用写任何东西 REParseError status = reg.Parse("{\\d\\d\\d\\d\\d\\d?}"); //这里传入匹配的规则 if (REPARSE_ERROR_OK != status) //REPARSE_ERROR_OK 表明解析正确 { return; //解析不正确返回 } CAtlREMatchContext mc; //模板中同样不用写任何东西,保持匹配的结果 BOOL matched = reg.Match(input.c_str(), &mc); //查找匹配, if(matched) //matched 为true,表明有匹配的字符串, { const CAtlREMatchContext::RECHAR* szStart = 0; //某个匹配的结果串的开始位置指针 const CAtlREMatchContext::RECHAR* szEnd = 0; //某个匹配的结果串的结束位置指针 mc.GetMatch(0, &szStart, &szEnd); //根据标号来获取某个结果串的开始结束位置指针, 0 表示第一个,可以使用以下的代码来匹配多个并获取 /* for (UINT nGroupIndex = 0; nGroupIndex ::RECHAR* szStart = 0; const CAtlREMatchContext::RECHAR* szEnd = 0; mcUrl.GetMatch(nGroupIndex, &szStart, &szEnd); ptrdiff_t nLength = szEnd - szStart; printf("%d: \"%.*s\"\n", nGroupIndex, nLength, szStart); } */ if(szStart == NULL) return; ptrdiff_t nLength = szEnd - szStart; string startstr = szStart; startstr = startstr.substr(0, nLength); //获取匹配的串 } /* . Matches any single character. [ ] Indicates a character class. Matches any character inside the brackets (for example, [abc] matches "a", "b", and "c"). ^ If this metacharacter occurs at the start of a character class, it negates the character class. A negated character class matches any character except those inside the brackets (for example, [^abc] matches all characters except "a", "b", and "c"). If ^ is at the beginning of the regular expression, it matches the beginning of the input (for example, ^[abc] will only match input that begins with "a", "b", or "c"). - In a character class, indicates a range of characters (for example, [0-9] matches any of the digits "0" through "9"). ? Indicates that the preceding expression is optional: it matches once or not at all (for example, [0-9][0-9]? matches "2" and "12"). + Indicates that the preceding expression matches one or more times (for example, [0-9]+ matches "1", "13", "666", and so on). * Indicates that the preceding expression matches zero or more times. ??, +?, *? Non-greedy versions of ?, +, and *. These match as little as possible, unlike the greedy versions which match as much as possible. Example: given the input "", matches "" while matches "". ( ) Grouping operator. Example: (\d+,)*\d+ matches a list of numbers separated by commas (such as "1" or "1,23,456"). { } Indicates a match group. The actual text in the input that matches the expression inside the braces can be retrieved through the CAtlREMatchContext object. \ Escape character: interpret the next character literally (for example, [0-9]+ matches one or more digits, but [0-9]\+ matches a digit followed by a plus character). Also used for abbreviations (such as \a for any alphanumeric character; see table below). If \ is followed by a number n, it matches the nth match group (starting from 0). Example: .*? matches "Contents". Note that in C++ string literals, two backslashes must be used: "\\+", "\\a", ".*?". $ At the end of a regular expression, this character matches the end of the input. Example: [0-9]$ matches a digit at the end of the input. | Alternation operator: separates two expressions, exactly one of which matches (for example, T|the matches "The" or "the"). ! Negation operator: the expression following ! does not match the input. Example: a!b matches "a" not followed by "b". Abbreviations CAtlRegExp can handle abbreviations, such as \d instead of [0-9]. The abbreviations are provided by the character traits class passed in the CharTraits parameter. The predefined character traits classes provide the following abbreviations. Abbreviation Matches \a Any alphanumeric character: ([a-zA-Z0-9]) \b White space (blank): ([ \\t]) \c Any alphabetic character: ([a-zA-Z]) \d Any decimal digit: ([0-9]) \h Any hexadecimal digit: ([0-9a-fA-F]) \n Newline: (\r|(\r?\n)) \q A quoted string: (\"[^\"]*\")|(\'[^\']*\') \w A simple word: ([a-zA-Z]+) \z An integer: ([0-9]+) */
发表评论
-
C 常用字符串函数
2012-07-06 09:52 696字符串长度 size_tstrlen(const ch ... -
分享一个java正则验证类
2012-07-06 09:45 574网上正则验证的很多,但是没找到一个比较集中的类,这个是我工 ... -
Android模拟器RAM修改方法 - 尤其是3.0
2012-07-06 09:30 685我们以Windows平台的SDK为例,这里Android开 ... -
jsp实现拍摄证件照代码
2012-07-05 20:45 925实现思路如下: 1.设置好拍照背景,如使用红布或者蓝布 ... -
vc2010下自动化组件开发示例
2012-07-03 13:43 893本文所指的自动化组件为 Automation 类型的 MF ... -
Flex DataGrid 控件知识汇总,创建、全选、删除、分页、样式
2012-07-02 12:23 785DataGrid控件是一个可以展示多列数据的列表控件。它是 ... -
Flash:Flex背景图像实现类似于html平铺拉伸(转)+1
2012-07-02 12:23 831在Flex中如果要实现 ... -
设备状态显示的flex实现说明
2012-07-02 12:22 590Author: Allan(吴进刚) 做这个图还是费 ... -
Flex权威指南3学习笔记之一------界面知识(四)
2012-07-02 12:22 663运用视图实现界面的切换 1.在DashBoard.m ... -
flex 日期下拉框,选择一段日期
2012-07-01 09:57 609在一般网页的制作过程中,我们做的程序,日期选择框,通过js ... -
flex4中的StyleManager 不生效
2012-07-01 09:56 768Flex4中的StyleManager到底怎么用呢?为什么 ... -
使用Adobe Flex开发Google Wave Gadgets
2012-07-01 09:56 528Adobe Flash Builder 4 简 ... -
Flex文件上传
2012-07-01 09:56 672今天花了一点时间 ... -
flex 联机游戏开发 - 中国象棋游戏:(一)核心逻辑
2012-06-30 16:22 760flex 联机游戏开发 - 中国象棋游戏:(一)核心逻辑 2 ... -
Flex技术在企业开发中的应用
2012-06-30 16:22 284Flex技术在企业开发中的应用 2010年10月08日 ... -
使用FLEX 和 Actionscript开发FLASH 游戏(一)
2012-06-30 16:22 559使用FLEX 和 Actionscript开发FLASH 游戏 ... -
FLEX和Actionscript开发FLASH游戏1
2012-06-30 16:22 610FLEX和Actionscript开发FLASH游戏1 20 ...
相关推荐
【简要介绍】 RegexDbg 是一款非常实用的正则表达式调试工具, ...正则表达式语法,特别方便于程序开发人员及其他正则表达式 编写人员测试使用。 版权无所谓有,但侵权者需受本方强烈谴责和严重抗议!╮( ̄▽ ̄")╭
本文摘要翻译了几篇文章的内容,简单介绍 ATL CAtlRegExp,GRETA,Boost::regex 等正则表达式库,这些表达式库使我们可以方便地利用正则库的巨大威力,给我们的工作提供了便利。
3:支持使用Boost库的正则表达式语法,ATL正则表达式语法。 4:使用正则表达式搜索内容后,可直接提取搜索内容。 5:直接调用迅雷进行下载,一步到位。 其它: 本软件采用最新的Boost库,VS2005开发,目前已...
HttpSourceViewer本项目来源于BiliBil视频网站,,十分感谢的分享。...(2)VC ++ RichEdit控件的使用(3)正则表达式使用boost :: xpressive库可参见使用ATL库(4)EasySize-立即调整对话框大小! 。 使用少量几个
atl开发指南 atl开发指南 atl开发指南 atl开发指南 atl开发指南
ATL的发明人Jim Springfield亲自作序推荐 四位顶尖的Windows编程专家倾力合作,绝对经典再现 COM、ATL开发人员的必备宝典 深入分析ATL实现COM内幕细节,展示COM应用中的各类漂亮技巧 本书主要介绍了ATL技术的...
适合人群: 对森林、地形、冰川等地物高度研究的人群 如何将星载lidar ICESAT-2的atl8和atl3结合,综合利用地理定位信息与地面高度信息
原始网页地址:正则表达式匹配规则:var url = ''var s = url.match(/post-enterprise-(\d+)-(\d).shtml/)console.log(s[2]);var content = $('.atl-content bbs-content').html().trim();主要思路:提取内容,
ATL技术内幕ATL技术内幕ATL技术ATL技术内幕内幕
Shell Renamer是一个Shell扩展,它支持正则表达式搜索以及替换重命名和文件名交换
ATL+WTL,Windows平台仍然是一对锋利的组合。 主要特点: http://blogs.msdn.com/b/vcblog/archive/2013/08/20/atl-and-mfc-changes-and-fixes-in-visual-studio-2013.aspx One of the major changes we made was ...
中文名: 深入解析ATL(第2版) 原名: ATL Internals, 2nd Edition Working with ATL 8 别名: ATL 作者: (美)塔瓦瑞斯译者: 赖仪灵 曹雨田 资源格式: PDF 版本: 扫描版 出版社: 电子工业出版社书号: 9787121049859...
VS2003下编译通过,包含两个ATL的例子,1)创建一个简单ATL对象,目的弹出一个Messagebox输出一句话,附加测试程序。程序中要注意COM的初始化。 2)创建一个ATL控件,嵌入到网页中,实现功能为,点击控件中三角形...
ATL开发指南.rar 完整的 ATL开发指南 提供下载 学习com atl编程非常好的资料
ATL接口映射宏详解 ATL接口映射宏详解 ATL接口映射宏详解
从基本算法与数据结构,到正则表达式与XML解析,从高性能数学计算,到资源 的分配与管理,从网络分布式计算环境,到组件模型创建,从静态多态性的维度扩展,到设计模式的自动生成,神奇的template显示出其令人...
PhoREAL_v3.26安装,可以批量处理ICESat2的ATL03和ATL08数据
AtlServer.zip webserver中用到的东西 有需要的下载
ATL简明教程 1. 介绍ATL的使用.
├─amd64 │ atl.lib │ atls.lib │ atlsd.lib │ atlthunk.lib │ ├─i386 │ atl.lib │ atls.lib │ atlsd.lib │ atlthunk.lib │ └─ia64 atl.lib atl21asm.lib atls.lib atlsd.lib