我
爱
.NET
好多人相信正则表达式是很难学会的,其实并不然,只要你多接触它,多用它,自然就会发现他的优秀之处,被他深深吸引,然后就是私信他的称赞他,以至于到处告诉别人这东西好学,这就是一种心理效应吧!
现在看看怎样编写正则表达式吧。首先,如果没有特定的软件,也不用着急,因为咱们可以用notepad(记事本)来编写代码,让它运行在windows平台上,这样的代码类型当然是javascript了,这是我的一个小程序片段:
</plaintext> </p> <p>这段代码就是想找到满足 re= /(ds) + (j+s)/ig;语句条件的字符与子字符串。</p></div> </div> <div class="artical-copyright mt26">©著作权归作者所有:来自51CTO博客作者xiangchao027的原创作品,如需转载,请注明出处,否则将追究法律责任</div> <div class="for-tag mt26"> <a href="https://blog.51cto.com/search/result?q=%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F" target="_blank">正则表达式</a> <div class="clear"></div> </div> <div class="more-list"> <p class="is-praise fl "><span type="1" blog_id="899807" userid='5262438'>0</span></p> <div class="share-box fr"> <p class="share"><i></i>分享</p> <div class="bdsharebuttonbox"> <span></span> <a class="bds_tsina" data-cmd="tsina" >微博</a> <a class="bds_sqq" data-cmd="sqq" >QQ</a> <a class="bds_weixin" data-cmd="weixin" >微信</a> <img src="/qr/qr-url?url=https%3A%2F%2Fblog.51cto.com%2Fxiangchao027%2F899807"> </div> </div> <p class="favorites favorites-opt fr"><i></i>收藏</p> <div class="clear"></div> </div> <div class="artical-list"> <a class="fl" href="https://blog.51cto.com/xiangchao027/899792" title="jquery学习的一点体会"> 上一篇:jquery学习的一点体会</a> <a class="fr" href="https://blog.51cto.com/xiangchao027/936794" title="JS的文件操作"> 下一篇:JS的文件操作</a> <div class="clear"></div> </div> <div class="author-module"> <div class="is-vip-bg-6 fl"> <a href="https://blog.51cto.com/xiangchao027" class="a-img" target="_blank"> <img class="is-vip-img is-vip-img-4" data-uid="5262438" src="https://ucenter.51cto.com/images/noavatar_middle.gif"> </a> </div> <div class="author-module-center fl"> <a class="h2" href="https://blog.51cto.com/xiangchao027" target="_blank" style="display:inline-block;">xiangchao027</a> <h3>4篇文章,3808人气,0粉丝</h3> </div> <div class="clear"></div> </div> </div> <div class="artical-Left" id="comment"> <!-- 发布评论 --> <div class="comment-creat"> <div class="is-vip-bg-6 fl"> <a href="https://blog.51cto.com/xiangchao027" class="header-img" target="_blank"> <img src="https://ucenter.51cto.com/images/noavatar_middle.gif"/> </a> </div> <div class="first-publish fr publish_user_id"> <textarea class="textareadiv textareadiv-publish" name="" id="" placeholder="提问和评论都可以,用心的回复会被更多人看到和认可" maxlength="500"></textarea> <div class="comment-push"> <p class="msg fl">Ctrl+Enter 发布</p> <p class="publish-btn blue-btn fr" flag="1">发布</p> <p class="cancel-btn cancel-btn-1 fr">取消</p> <div class="clear"></div> </div> <input type="hidden" class="user_id" value="5262438"> <input type="hidden" class="reply_id" value="899807"> <input type="hidden" class="first_pid" value=""> </div> <div class="clear"></div> </div> <div class="commentList"> </div> <!-- page --> <div class="act_pageList_box"></div> </div> <!-- end left --> <!-- right start --> <div class="Blog-Right artical-Right"> <a class="catalog"></a> <a class="scrollTop" href="javascript:void(0);" onclick="$(window).scrollTop(0);"></a> </div> <!-- end right --> </div> <div class="special-column"> <div class="Page M764"> <div class="column-1"> <h2 class="column-tit">推荐专栏<a href="/cloumn/index?utm_source=p" target="_blank"><span class="recommend-more-span" style="">更多</span></a></h2> <div class="column-box"> <a href="https://blog.51cto.com/cloumn/detail/4" class="a-img fl cloumn-tab-par" target="_blank"> <img src="https://s1.51cto.com/images/blog/201804/27/92f96bca4a81e7c15a63e696e2a8d8e5.jpg"> </a> <div class="center fl"> <a class="h2 white-space" href="https://blog.51cto.com/cloumn/detail/4" target="_blank"> 微服务技术架构和大数据治理实战</a> <h3 class="white-space">大数据时代的微服务之路</h3> <h4 class="white-space">共18章 | <a href="https://blog.51cto.com/ityouknow" target="_blank">纯洁微笑</a></h4> <h5><span class="price"> ¥51.00 </span><span>692人订阅</span></h5> </div> <div class="right fr"> <a class="cloumn-subscribe" cid="4" href="/cloumn/detail/4" ask='1' target="_blank">订 阅</a> </div> <div class="clear"></div> </div> <div class="column-box"> <a href="https://blog.51cto.com/cloumn/detail/13" class="a-img fl cloumn-tab-par" target="_blank"> <img src="https://s1.51cto.com/images/blog/201808/03/a940c66317ecbe58436a2ad3831c2d7d.png"> </a> <div class="center fl"> <a class="h2 white-space" href="https://blog.51cto.com/cloumn/detail/13" target="_blank"> 基于Python的DevOps实战</a> <h3 class="white-space">自动化运维开发新概念</h3> <h4 class="white-space">共20章 | <a href="https://blog.51cto.com/yuhongchun" target="_blank">抚琴煮酒</a></h4> <h5><span class="price"> ¥51.00 </span><span>503人订阅</span></h5> </div> <div class="right fr"> <a class="cloumn-subscribe" cid="13" href="/cloumn/detail/13" ask='1' target="_blank">订 阅</a> </div> <div class="clear"></div> </div> </div> <div class="column-2" style="margin-top: 76px;"> <h2 class="column-tit">猜你喜欢</h2> <div class="column-box"> <a class="white-space" href="https://blog.51cto.com/xiangchao027/2028509?source=dra" target="_blank">我的友情链接</a> <a class="white-space" href="https://blog.51cto.com/xiangchao027/936794?source=dra" target="_blank">JS的文件操作</a> <a class="white-space" href="https://blog.51cto.com/14449530/2437903?source=drt" target="_blank">路由表的路由来源有哪些?</a> <a class="white-space" href="https://blog.51cto.com/lavasoft/97730?source=drt" target="_blank">IntelliJ Idea 常用快捷键列表</a> <a class="white-space" href="https://blog.51cto.com/lxsym/866331?source=drt" target="_blank">[shell] if else以及大于、小于、等于逻辑表达式</a> <a class="white-space" href="https://blog.51cto.com/tonyguo/176104?source=drt" target="_blank">Windows路由表详解</a> <a class="white-space" href="https://blog.51cto.com/liweizhong/617535?source=drt" target="_blank">常用邮箱、网盘地址列表</a> <a class="white-space" href="https://blog.51cto.com/tianzt/171759?source=drt" target="_blank">oracle表分区详解</a> <a class="white-space" href="https://blog.51cto.com/14451009/2441677?source=drt" target="_blank">shell 正则表达式</a> <a class="white-space" href="https://blog.51cto.com/simeon/101003?source=drt" target="_blank">最权威的×××号码的正则表达式</a> <a class="white-space" href="https://blog.51cto.com/lavasoft/172292?source=drt" target="_blank">Spring切入点表达式常用写法</a> <a class="white-space" href="https://blog.51cto.com/14449563/2441540?source=drt" target="_blank">三剑客之sed,awk,grep,egrep</a> <a class="white-space" href="https://blog.51cto.com/5103803/2449492?source=drh" target="_blank">一次有趣的Linux下.Net Core与C语言的合作开发体验:生成Linux标准的用户密码串</a> <a class="white-space" href="https://blog.51cto.com/dream1135134786/2379612?source=drh" target="_blank">ASPNetCore MVC ModelValidation-ajax</a> <a class="white-space" href="https://blog.51cto.com/eiceblue/2128543?source=drh" target="_blank">C#如何设置Excel文档保护——工作簿、工作表、单元格</a> <a class="white-space" href="https://blog.51cto.com/zhoufoxcn/2114174?source=drh" target="_blank">在.NET数据库访问方面的Dapper类库介绍</a> <a class="white-space" href="https://blog.51cto.com/eiceblue/2107093?source=drh" target="_blank">C#/VB.NET 如何添加、获取、删除PDF附件</a> <a class="white-space" href="https://blog.51cto.com/eiceblue/2105349?source=drh" target="_blank">C#/VB.NET 创建PDF项目符号列表和多级编号列表</a> <a class="white-space" href="https://blog.51cto.com/eiceblue/2096535?source=drh" target="_blank">C# /VB.NET 操作Word (一)——插入、修改、删除Word批注</a> <a class="white-space" href="https://blog.51cto.com/eiceblue/2094580?source=drh" target="_blank">C# 操作Excel数据透视表</a> <div class="clear"></div> </div> </div> </div> </div> <div class="group_img_box"> <div class="group_git_box"> <img src="https://s1.51cto.com/images/blog/201910/25/e44823f12c0ccbfd99decb605b02ec10.png" style="width:50px;height:50px;"/> <!--<img src="https://s1.51cto.com/images/blog/201810/22/078772c84eb23213ea90f577d9316ce4.png"/>--> </div> <div class="group_code_box"> <img src="https://static1.51cto.com/edu/blog/mobile/images/left-qr.jpg" width="130" height="130"> <p>扫一扫,领取大礼包</p> </div> </div> <div class="the-lowest-bg"> <div class="the-lowest Page M764"> <p class="is-praise fl "><span type="1" blog_id="899807" userid='5262438'></span></p> <p class="b-favorites favorites-opt fl"><i></i><b>0</b></p> <a class="b-reply fl"><i></i><font class="comment_number"></font></a> <div class="b-share fl"> <i></i>分享 <div class="bdsharebuttonbox"> <a class="bds_tsina p2" data-cmd="tsina"></a> <a class="bds_sqq p3" data-cmd="sqq"></a> <a class="bds_weixin p1" data-cmd="weixin"><em class="code-icon"></em><img class="code-img" src="/qr/qr-url?url=https%3A%2F%2Fblog.51cto.com%2Fxiangchao027%2F899807"></a> </div> </div> <a href="https://blog.51cto.com/xiangchao027" class="b-name fr">xiangchao027</a> <div class="is-vip-bg-6 fr"> <a href="https://blog.51cto.com/xiangchao027" class="b-img"><img class="is-vip-img is-vip-img-4" data-uid="5262438" src="https://ucenter.51cto.com/images/noavatar_middle.gif"></a> </div> <div class="clear"></div> </div> </div> </div> <!-- 老博文美观处理 --> <script src="https://static1.51cto.com/edu/blog/js/shCores.js"></script> <script src="https://static1.51cto.com/edu/blog/js/countDown.js"></script> <script> var praise_url = 'https://blog.51cto.com/praise/praise' addReply_url = 'https://blog.51cto.com/comments/add' removeUrl = 'https://blog.51cto.com/comments/del' blog_id = '899807' pv_log_info = { 'pv_type':'blog', 'user_id':'5262438', 'blog_id':'899807' }; rid = '0' is_comment = '0' comment_list = '/blog/ajax-comment-list' comment_sort = "asc" index_url = 'https://blog.51cto.com/xiangchao027'; uc_url = 'https://ucenter.51cto.com/' blog_url = 'https://blog.51cto.com/' img_url = 'https://static1.51cto.com/edu/blog/' i_user_id = '' c_user_id ='5262438' collect_url = 'https://blog.51cto.com/collect/add' is_old = '1' nicknameurl = 'https://blog.51cto.com/xiangchao027' nickname = 'xiangchao027' myself = window.location.href; $('.you-like-list li:odd').css({'margin-left': '10%'}); $('.column-box a:odd').addClass('left-list') $('.myUrl').text(myself).click(function(){window.open(myself)}) setTimeout(function(){$('.Footer').css({'margin-top':'-50px'})},50) if(is_old==1){ // SyntaxHighlighter.all(); insertCodeElement("<div style=\"position:absolute;left:20;top:20;height:30px;width:30px;cursor:hand;background:#aabbaa;color:#fff;padding:5px;\">\u6211<\/div>\r\n<div style=\"position:absolute;left:45;top:45;height:30px;width:30px;cursor:hand;background:#00ffaa;color:#fff;padding:5px;\">\u7231<\/div>\r\n<div style=\"position:absolute;left:60;top:60;height:30px;width:30px;cursor:hand;background:#aabbaa;color:#fff;padding:5px;\">.NET<\/div>\r\n<div style=\"margin:10px;background-color:#ffaa00;color:#0000ff;cursor:cross;\"> \u597d\u591a\u4eba\u76f8\u4fe1\u6b63\u5219\u8868\u8fbe\u5f0f\u662f\u5f88\u96be\u5b66\u4f1a\u7684\uff0c\u5176\u5b9e\u5e76\u4e0d\u7136\uff0c\u53ea\u8981\u4f60\u591a\u63a5\u89e6\u5b83\uff0c\u591a\u7528\u5b83\uff0c\u81ea\u7136\u5c31\u4f1a\u53d1\u73b0\u4ed6\u7684\u4f18\u79c0\u4e4b\u5904\uff0c\u88ab\u4ed6\u6df1\u6df1\u5438\u5f15\uff0c\u7136\u540e\u5c31\u662f\u79c1\u4fe1\u4ed6\u7684\u79f0\u8d5e\u4ed6\uff0c\u4ee5\u81f3\u4e8e\u5230\u5904\u544a\u8bc9\u522b\u4eba\u8fd9\u4e1c\u897f\u597d\u5b66\uff0c\u8fd9\u5c31\u662f\u4e00\u79cd\u5fc3\u7406\u6548\u5e94\u5427\uff01<\/div><br \/>\r\n<div style=\"margin:10px;background-color:#00aa00;color:#aabbbb;cursor:cross;\"> \u73b0\u5728\u770b\u770b\u600e\u6837\u7f16\u5199\u6b63\u5219\u8868\u8fbe\u5f0f\u5427\u3002\u9996\u5148\uff0c\u5982\u679c\u6ca1\u6709\u7279\u5b9a\u7684\u8f6f\u4ef6\uff0c\u4e5f\u4e0d\u7528\u7740\u6025\uff0c\u56e0\u4e3a\u54b1\u4eec\u53ef\u4ee5\u7528notepad\uff08\u8bb0\u4e8b\u672c\uff09\u6765\u7f16\u5199\u4ee3\u7801\uff0c\u8ba9\u5b83\u8fd0\u884c\u5728windows\u5e73\u53f0\u4e0a\uff0c\u8fd9\u6837\u7684\u4ee3\u7801\u7c7b\u578b\u5f53\u7136\u662fjavascript\u4e86\uff0c\u8fd9\u662f\u6211\u7684\u4e00\u4e2a\u5c0f\u7a0b\u5e8f\u7247\u6bb5\uff1a<\/div><br \/>\r\n<p> \r\n<plaintext>\r\n\r\n<\/plaintext>\r\n<\/p>\r\n<p>\u8fd9\u6bb5\u4ee3\u7801\u5c31\u662f\u60f3\u627e\u5230\u6ee1\u8db3 re= \/(ds) + (j+s)\/ig;\u8bed\u53e5\u6761\u4ef6\u7684\u5b57\u7b26\u4e0e\u5b50\u5b57\u7b26\u4e32\u3002<\/p>", '#result'); } function insertCodeElement(content, container){ container = container || document; // 创建一个 div 来放置获取到的内容,这样就可以把 content 字符串内容转换成 dom // 方便我们对这个 dom 进行操作(只是创建 div,并没有插入到文档,他只存在于内存中) var parent = document.createElement('div'); parent.innerHTML = content; // 找到 parent 中的所有 pre 标签,并遍历 var $pres = $(parent).find('pre'); $pres.each(function(index, el) { var $el = $(el), html = $el.html(), code = document.createElement('code'), elClass = $el.attr('class'); if(!elClass) {return}; // 获取 pre 标签中,class 属性中包含的本段代码所有的编程语言 var language = elClass.substring(6, elClass.indexOf(';')); code.className = 'language-' + language; code.innerHTML = html; $el.html(code); }); $(container).html(parent.innerHTML); // 最后,调用 Prism 的方法来高亮代码 Prism.highlightAll(); } window._bd_share_config={ "common":{ "bdText":"正则表达式学习", "bdDesc":$("#abstract_bdshare").text(), "bdMini":"2", "bdMiniList":false, "bdPic":"https://s1.51cto.com/images/201710/25/bd540a4f14d822f6e69087758699358b.jpg", "bdStyle":"0", "bdSize":"16" }, "share":{} }; with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)]; setTimeout(function(){ $('.bdsharebuttonbox a').removeAttr('title') },1000); var now_time = 1579095688; //当前时间 setInterval(function(){now_time+=0.01},10); // 初始化页面 updatePage(); // 页面tab切换 zDate.visibilityAction(function () { zDate.getServerTime(function (e) { var updateResult = new Date(e).getTime(); now_time = +updateResult.toString().substr(0, 10); updatePage(); }); }) // 定时刷新现在时间 setInterval(function () { zDate.getServerTime(function (e) { var updateResult = new Date(e).getTime(); now_time = +updateResult.toString().substr(0, 10); updatePage(); }); }, 1000*60*2); // 页面刷新 function updatePage() { $('.presell').each(function(index, item) { var end_time = $(this).data('end'); // 结束时间 if (!end_time) { return; } var me = $(this); if (me.lastTime) { clearInterval(me.lastTime); me.lastTime = null; } else { me.lastTime = setInterval(function() { zDate.setLastTimePc(me.find('.timespan'), (end_time*1000-now_time*1000), me.lastTime, function() { me.parents('.right').find('.cloumn-subscribe').removeClass('presell-color'); me.remove(); $('.pre-tips').remove(); }); }, 10); } }); } //二维码显示 $(".group_git_box").hover(function(){ $(this).parents('.group_img_box').find(".group_code_box").show() },function(){ $(this).parents('.group_img_box').find(".group_code_box").hide() }) </script> </div> <script src="https://static1.51cto.com/edu/blog/js/marked.min.js"></script><script src="https://static1.51cto.com/edu/blog/js/highlight.js"></script><script src="https://static1.51cto.com/edu/blog/js/detail_mp.js"></script><script src="https://static1.51cto.com/edu/blog/js/detail.js"></script><script src="https://static1.51cto.com/edu/blog/js/details_new.js"></script><script src="https://static1.51cto.com/edu/blog/js/copy.js"></script> <div style="display:none"> <iframe frameborder="0" scrolling="no" width="0" height="0" src="https://log.51cto.com/pageview.php?frompos=blog_art"></iframe> </div> <script src="https://static1.51cto.com/edu/blog/js/pvlog.js"></script> <script> $(".gotop").click(function(){$(window).scrollTop(0)}) </script> <script type="text/javascript"> //百度统计代码 var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?2283d46608159c3b39fc9f1178809c21"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); //自动推送链接 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> <script type='text/javascript'> var _vds = _vds || []; window._vds = _vds; (function(){ _vds.push(['setAccountId', '8c51975c40edfb67']); (function() { var vds = document.createElement('script'); vds.type='text/javascript'; vds.async = true; vds.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'assets.growingio.com/vds.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(vds, s); })(); })(); //document.write(decodeURI("%3Cscript src='https://tongji.51cto.com/frontend/tj.gif' type='text/javascript'%3E%3C/script%3E")); </script> <script> var uid = ''; var BLOG_URL = 'https://blog.51cto.com/'; </script> <script src="https://static1.51cto.com/edu//blog/js/jquery.cookie.js"></script> <script src="https://static1.51cto.com/edu/blog/js/time-on-page.js" charset="utf-8"></script> <script> (function(){ var wh=$(window).height(),fh=$('.Footer').outerHeight(true),hh=$('.Header').outerHeight(true) $('.Content-box').css({'min-height': wh-fh-hh}) })() </script> </body> </html>