Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- # how one would normally do it
- def contains_foobar_1(s):
- return "foobar" in s.lower()
- # how one does it with regex, properly
- def contains_foobar_2(s):
- return re.search(r'foobar', s, flags = re.IGNORECASE) is not None
- # how one does it with regex
- # (trying to squeeze every bit of efficiency outta it)
- _foobar_re = re.compile(r'foobar', flags = re.IGNORECASE)
- def contains_foobar_3(s):
- return _foobar_re.search(s) is not None
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement