Other Resources:
Regular Expression with Logical AND
How to write AND logic in regular expression?
How to build a regular expression to identify the following email paragraph as a spam message because it contains the word "bank", "account" and "money"?
"I am inviting you for a business deal where this money will be shared between of us in the ratio of 60/40 percentage. Am assured you that within (7) seven banking working days, this said amount will enter your given Bank account with immediate alacrity. If you agree to my business proposal, further details of the transfer will be forwarded to you as soon as I receive your wiliness to join hand with me."
✍: FYIcenter.com
There is no logical AND operation directly offered in the regular expression standard. But you can use mutiple look ahead expressions to perform AND operations indirectly.
Here are some examples of using look ahead expressions for logical AND operations:
^(?=.*Black)(?=.*Friday). # matches any string with "Black" and "Friday" ^(?=.*Chicken)(?=.*Egg). # matches any string with "Chicken" and "Egg"
The regular expression to capture some common spamming terms is:
^(?=.*bank)(?=.*account)(?=.*money).
^ - beginning of the string
(?=bank) - look ahead for "bank"
(?=account) - look ahead for "bank"
(?=money) - look ahead for "bank"
. - the first character.
2015-05-22, 0👍, 0💬
Popular Posts:
How to capture the MSN (Microsoft Network) bot entries from Web log file? Here are some Web log file...
How to write a regular expression to parse key-value entries from Windows .INI files? Here is an exa...
All credit card numbers issued by JCB have 3 sets of numbers: JCB cards start with 2131 have 15 digi...
All credit card numbers issued by Diners Club must start with 300 through 305, 36 or 38 and have 14 ...
How to capture the Sogou web spider entries from Web log file? Here are some Web log file entries: 1...