| 域名空间 下载中心 社区论坛 信息公告 my小屋 |
![]() |
联系我们 设为首页 加入收藏 |
|
首页 | 新闻资讯 | 编程开发 | 网页设计 | 图形图象 | 网络媒体 | 网站模板 | 数 据 库 | 投稿 论坛 | 操作系统 | 系统优化 | 网络安全 | 黑客技术 | 硬件学堂 | 硬件报价 | 服 务 器 | 地图 专题 | 应用软件 | 聊天通讯 | q q 专栏 | 建站经验 | 在线工具 | 站长club | 注 册 表 | 旧版 社会 | 游戏娱乐 | 设计欣赏 | 疑难解答 | 社区论坛 | 韩国素材 | 素材图库 | 广告服务 | 服务 |
| 新版上线![旧版] | |||||
注:打开慢时请稍等
正则表达式疑惑之二:基本语法http://www.iyit.net 日期:2006-10-6 15:40:35 来源:iyit.net收集 点击: |
\ general escape character with several uses ^ assert start of subject (or line, in multiline mode) $ assert end of subject (or line, in multiline mode) . match any character except newline (by default) [ start character class definition ] end character class definition ¦ start of alternative branch ( start subpattern ) end subpattern ? extends the meaning of (, also 0 or 1 quantifier, also quantifier minimizer * 0 or more quantifier + 1 or more quantifier { start min/max quantifier } end min/max quantifier \a alarm, that is, the bel character (hex 07) \cx "control-x", where x is any character \e escape (hex 1b) \f formfeed (hex 0c) \n newline (hex 0a) \r carriage return (hex 0d) \t tab (hex 09) \xhh character with hex code hh \ddd character with octal code ddd, or backreference \d any decimal digit \d any character that is not a decimal digit \s any whitespace character \s any character that is not a whitespace character \w any "word" character \w any "non-word" character \b word boundary \b not a word boundary \a start of subject (independent of multiline mode) \z end of subject or newline at end (independent of multiline mode) \z end of subject (independent of multiline mode) 疑问:下面这些是什么含义,如何使用? \b word boundary \b not a word boundary \a start of subject (independent of multiline mode) \z end of subject or newline at end (independent of multiline mode) \z end of subject (independent of multiline mode) --------------------------------------------------------------- \b 匹配一个单词边界,也就是指单词和空格间的位置。例如, ’er\b’ 可以匹配"never" 中的 ’er’,但不能匹配 "verb" 中 的 ’er’。 \b 匹配非单词边界。’er\b’ 能匹配 "verb" 中的 ’er’,但不能匹 配 "never" 中的 ’er’。 这是我所知道的。关于你说的另外的3个用法,我没有用过,也没有见人用过,请教一下其他人再^_^ 浅妄薄见,望与斟酌 --------------------------------------------------------------- 以前没用过,测试结果如下 \a和^的区别 不管有没有multiline, \a都只匹配串的开始位置 而当设了multiline,^ 也匹配 '\n' 或 '\r' 之后的位置 \z\z和$的区别 不管有没有multiline, \z\z都只匹配串的结束位置 而当设了multiline,$ 也匹配 '\n' 或 '\r' 之前的位置 \z和\z的区别 \z不管最后一行是否是新行,忽略,但\z不忽略 <? $str='1234 1234 51234 '; echo "<br>^:".preg_replace(" ¦^1234 ¦m","",$str); echo "<br>a:".preg_replace(" ¦\a1234 ¦m","",$str); echo "<br>$:".preg_replace(" ¦1234$ ¦m","",$str); echo "<br>z:".preg_replace(" ¦1234\z ¦m","",$str); echo "<br>z:".preg_replace(" ¦1234\z ¦","",$str); ?> 编辑:黑鹰 [发送给好友] [打印本页] [关闭窗口] [返回顶部] 上一篇:怎样计算两个日期相差的天数? 下一篇:分割中文字符如何避免切割半个中文字符? 转载请注明来源:www.iyit.net 特别声明: 本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。 |
| 相关文章 | ||||
| 设置首 页 - 版权声明 - 广告服务 - 关于我们 - 联系我们 - 友情连接 |
| |||||||