Skip to main content

Posts

Showing posts from January, 2019

regex in python python hunter

Regular Expressions is a powerful concept if understood clearly you can save your valuable time to extract out the particular text from huge string or paragraph. It is wildly pronounced as regex, it can help you to automate the boring stuff, like searching particular text form log files, python used this same concept in web scrapping. Below are some common examples to understand the regex. Method names will help you to have an idea that what exactly the regex is intended to do. if you don't understand any regex or want to create your own regex with your requirements then you can comment below, i'll reach you ASAP. Thanks. import re def phoneNumberPattern (): print ( "*" * 10 ) print ( "phoneNumberPattern()" ) regexObj = re . compile( r'\d\d\d-\d\d\d-\d\d\d\d' ) mo = regexObj . search( 'Find my phone number from this string 998-805-4332' ) print (mo . group()) def grouping (): print ( "*"