start() in regex in python by R4R Team

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

Syntax-

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

Example-
string is s="This is string"
x=re.search('is',s)
x.start() will return 5


program-

#import the re module
import re

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

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

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

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


output-

5
16
8




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!