首页 > 其他 > 详细

[Regex Expression] Confirmative -- World bundry

时间:2016-03-05 23:21:49      阅读:118      评论:0      收藏:0      [点我收藏+]

String to check:

技术分享

 

As it turns out, our potential shipmates are extremely superstitious. As such, we do not want anyone to enter certain words in their comments.

Requirements: 

1. Let‘s start checking for bad words within a sentence. We can begin with sinkas our first bad word. We will want to make sure this word is by itself and not part of a larger word.

/\bsink\b/gim

技术分享

 

2. Looking good, but there are more bad words we need to account for. Let‘s also check for ‘wreck‘.

/\b(sink|wreck)\b/gim

技术分享

 

3. Almost finished. Our final bad word to match is ‘disaster‘.

/\b(sink|wreck|disaster)\b/gim

技术分享

-------------------------------------

 

/http(s)?:\/\/(www\.)?twitter(\.com|\.org)\/codeschool/gm

技术分享

[Regex Expression] Confirmative -- World bundry

原文:http://www.cnblogs.com/Answer1215/p/5245989.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!