Repetitions

Python में Regular Expressions

Maria Eugenia Inzaugarat

Data Science

Repeated characters

नीचे दी गई string को वैलिडेट करें:

Python में Regular Expressions

Repeated characters

नीचे दी गई string को वैलिडेट करें:

Python में Regular Expressions

Repeated characters

नीचे दी गई string को वैलिडेट करें:

Python में Regular Expressions

Repeated characters

नीचे दी गई string को वैलिडेट करें:

import re
password = "password1234"
re.search(r"\w\w\w\w\w\w\w\w\d\d\d\d", password)
<re.Match object; span=(0, 12), match='password1234'>
Python में Regular Expressions

Repeated characters

नीचे दी गई string को वैलिडेट करें:

import re
password = "password1234"
re.search(r"\w{8}\d{4}", password)
<re.Match object; span=(0, 12), match='password1234'>

Quantifiers:

एक मेटा-कैरेक्टर जो regex इंजन को बताता है कि बाएँ वाले कैरेक्टर को कितनी बार मैच करना है.

Python में Regular Expressions

Quantifiers

  • एक या अधिक: +

 

text = "Date of start: 4-3. Date of registration: 10-04."
re.findall(r"       ", text)
Python में Regular Expressions

Quantifiers

  • एक या अधिक: +

 

text = "Date of start: 4-3. Date of registration: 10-04."
re.findall(r"\d+-   ", text)
Python में Regular Expressions

Quantifiers

  • एक या अधिक: +

 

text = "Date of start: 4-3. Date of registration: 10-04."
re.findall(r"\d+-\d+", text)
['4-3', '10-04']
Python में Regular Expressions

Quantifiers

  • शून्य या अधिक बार: *

 

my_string = "The concert was amazing! @ameli!a @joh&&n @mary90"

re.findall(r"@\w+\W*\w+", my_string)
['@ameli!a', '@joh&&n', '@mary90']
Python में Regular Expressions

Quantifiers

  • शून्य या एक बार: ?

 

text = "The color of this image is amazing. However, the colour blue could be brighter."

re.findall(r"colou?r", text)
['color', 'colour']
Python में Regular Expressions

Quantifiers

  • कम-से-कम n बार, अधिक-से-अधिक m बार: {n, m}

 

phone_number = "John: 1-966-847-3131 Michelle: 54-908-42-42424"
re.findall(r"                          ", phone_number)
Python में Regular Expressions

Quantifiers

  • कम-से-कम n बार, अधिक-से-अधिक m बार: {n, m}

 

phone_number = "John: 1-966-847-3131 Michelle: 54-908-42-42424"
re.findall(r"\d{1,2}-                 ", phone_number)
Python में Regular Expressions

Quantifiers

  • कम-से-कम n बार, अधिक-से-अधिक m बार: {n, m}

 

phone_number = "John: 1-966-847-3131 Michelle: 54-908-42-42424"
re.findall(r"\d{1,2}-\d{3}-           ", phone_number)
Python में Regular Expressions

Quantifiers

  • कम-से-कम n बार, अधिक-से-अधिक m बार: {n, m}

 

phone_number = "John: 1-966-847-3131 Michelle: 54-908-42-42424"
re.findall(r"\d{1,2}-\d{3}-\d{2,3}-\d{4,}", phone_number)
['1-966-847-3131', '54-908-42-42424']
Python में Regular Expressions

Quantifiers

  • बिल्कुल बाएँ वाले पर

    • r"apple+": + "e" पर लागू होता है, पूरे apple पर नहीं
Python में Regular Expressions

अभ्यास करते हैं!

Python में Regular Expressions

Preparing Video For Download...