473,320 Members | 1,988 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

find the index of a pattern occurred in a string

3
Hi,

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?

Thanks.
Jul 14 '08 #1
1 2347
bvdet
2,851 Expert Mod 2GB
Use match object methods start() and end() to determine the starting and ending index numbers of the matched substring.
Jul 14 '08 #2

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

Similar topics

10
by: Andrew Dalke | last post by:
Is there an author index for the new version of the Python cookbook? As a contributor I got my comp version delivered today and my ego wanted some gratification. I couldn't find my entries. ...
13
by: Brian | last post by:
Hi all... This question is more for the GURUs out there. It is not a question on how to do something, but why it happens, and I am trying to figure out if there is a pattern. I am using IE, but...
3
by: kittykat | last post by:
Hi, I was wondering if you could help me. I am writing a program in C++, and the problem is, i have very limited experience in this language. I would like my user to enter a specific pattern, and...
108
by: Bryan Olson | last post by:
The Python slice type has one method 'indices', and reportedly: This method takes a single integer argument /length/ and computes information about the extended slice that the slice object would...
3
by: Professor Frink | last post by:
First off, I apologize if this gets long. I'm simply trying to give you all enough information to help me out. I'm writing (almost finished, actually), my first VB.Net application. It's a forms...
10
by: ksrajalakshmi | last post by:
Hai , in a textbox am having text as "(20/100)+pay1*pay2" .it's a formula. and stored in a particular variable. string strformula="(20/100)+pay1*pay2" ; i've to substitute the value of the...
14
by: micklee74 | last post by:
hi say i have string like this astring = 'abcd efgd 1234 fsdf gfds abcde 1234' if i want to find which postion is 1234, how can i achieve this...? i want to use index() but it only give me the...
0
by: Xah Lee | last post by:
Interactive Find and Replace String Patterns on Multiple Files Xah Lee, 2006-06 Suppose you need to do find and replace of a string pattern, for all files in a directory. However, you do not...
9
by: WebArchitect | last post by:
I have a text file. My text file contains lines with double quotes around it. I trying to code if a line has double quotes around it Then make it bold My code is below and it is not working....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.