HOWTO : Python string search

Quick self-note 🙂

different ways to search for content in a string in python

  • Basic (and quickest)
    • if 'content' in string:
  • String.find (second quickest and doesn’t need additional module)
    • if string.find('content'):
  • re.match (uses regex engine, most powerful)
    • import re
    • if'content', string)

Good discussion here :

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.