end in regex in python by R4R Team

- end() used in regular expression in python, which find the end index value of the match pattern in the string.

Syntax-

x=re.search(pattern,string)
x.end()

Example-

string is s="This is string"
x=re.search('is',s)
x.end() will return 7


program-

#import the re module
import re

#Given string is
str = "What is programming language"

#upper index value of 'is'
x = re.search('is', str)
print(x.end())

#upper index value of 'in'
x = re.search('in', str)
print(x.end())

#upper index value of 'program'
x = re.search('program', str)
print(x.end())


output-

7
18
15




Leave a Comment:
Search
Categories
R4R Team
R4Rin Top Tutorials are Core Java,Hibernate ,Spring,Sturts.The content on R4R.in website is done by expert team not only with the help of books but along with the strong professional knowledge in all context like coding,designing, marketing,etc!