[Regex Expression] Confirmative -- World bundry

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 'sink'as 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

[Regex Expression] Confirmative -- World bundry_第1张图片

 

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

[Regex Expression] Confirmative -- World bundry_第2张图片

 

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_第3张图片

你可能感兴趣的:([Regex Expression] Confirmative -- World bundry)