By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,857 Members | 1,816 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,857 IT Pros & Developers. It's quick & easy.

find the index of a pattern occurred in a string

P: 3

I am absolutely a beginner in Python. How can I find an index of a regular expression pattern if it matches within a string? For example a string: 'abc:def' and I want to get the index of ':' (colon) using the regular expression such as r'[^\w\s]. JAVA supports regular expression in the version of 'indexOf ()' function. How these could be done in Python?

Jul 14 '08 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 2.5K+
P: 2,851
Use match object methods start() and end() to determine the starting and ending index numbers of the matched substring.
Jul 14 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.