UrbanPro
true

Learn Python Training from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Back Reference In Python Regex

Logeswaran
07/09/2017 0 0

What if your interviewer asks about this?

We know Regex have some useful functions like:

  • match  (  Ex: re.match(pattern,dataSource)   )
  • search (  Ex: re.search(pattern,dataSource)   )
  • sub      (  Ex: re.sub(pattern,replaceStr,dataSource)   
  • findall  (  Ex: re.findall(pattern,dataSource)   )
Do we heard the term back reference in python?
Let me explain sample examples: how to check whether the given string follows the given pattern?
 
Sample program implementation:
import re                   #re - Python Library for regular-expression 
sampleString="aabab"
findObj=re.match('(.+)\\1(.+)\\1\\2',sampleString)
                                #Above \\1 and \\2 back referencing the respective group of pattern
print findObj.group()
 
Output: Matched object: aabab
0 Dislike
Follow 2

Please Enter a comment

Submit

Other Lessons for You

Black in Python
When you are upturn in your career from beginner to experienced in programming world, your team will start looking at ‘how you are writing?’ Here the responsibility piling up. Okay,...

Facebook Analytics
Assume how the Facebook application will store the millions of customer's record in real-time: facebook = { 'jose': { 'name': 'jose', 'age': 33, 'hobby': , # cricket,football 'mobile': 1111111111, 'email':...

Decorator Advanced ( Passing Parameter )
Hope you read our previous note about the basic concept of python-decorators, if not, please read first Let see what are the possible ways to utilise the decorators in real time.Well, here we are going...

Decorator in Python - Simplified
By definition, a decorator is a function that takes another function andextends(/decorates) the behaviour of the latter function without explicitly modifying it.Let see how we can apply decorators for...

Python Concurrent v/s Parallel Programming
Concurrent means, more than one task happening at a time in interleaved fashion, (ie.,)Task 'A' starts, and Task 'B' starts before task 'A' finish, after processing its(A and B) own purpose both the task...
X

Looking for Python Training Classes?

The best tutors for Python Training Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Python Training with the Best Tutors

The best Tutors for Python Training Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more