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

Use IPython shell for better understanding of python
Hi All, Even though there are many editors like IDLE, PyDev, PyCharm are available for python, it is very advantageous to use ipython as an interactive shell for Pyhon. How to install it? pip install...

Writing Simple programs in Python(cont.)
To start writing simple programs in Python, we have to know firstly the SW development process and then we also have to know a bit about the language in which we wish to code,in this case,python, to get...

Assignment operators
Operation Syntax Comment Assignment = Control flow right to left Add AND += Incremental Subtract AND -= Decremental Multiply AND *= Multiplicative increment Division...

Machine Learning With Python
1. Course description: Machine Learning with Python has been designed for the provision of having strong hold in creating Machine learning algorithms with the base of Python. This has been preferred as...
J

Code: Gantt Chart: Horizontal bar using matplotlib for tasks with Start Time and End Time
import pandas as pd from datetime import datetimeimport matplotlib.dates as datesimport matplotlib.pyplot as plt def gantt_chart(df_phase): # Now convert them to matplotlib's internal format... ...
R

Rishi B.

0 0
0

Looking for Python Training classes?

Learn from Best Tutors on UrbanPro.

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
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