Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python re return index of match

import re

target_string = "Emma is a basketball player who was born on June 17, 1993"
# match method with pattern and target string using match()
result = re.match(r"w{10}", target_string)
# printing  match
print("Match: ", result) # None

# using search()
result = re.search(r"w{10}", target_string)
# printing match
print("Match value: ", result.group()) # basketball
print("Match starts at", result.start()) # index 10
Comment

PREVIOUS NEXT
Code Example
Python :: How to allow discord bot to respond to webhook. Python. Discord.py 
Python :: installing blacksheep 
Python :: decoding to str: need a bytes-like object, list found 
Python :: problème barbier semaphore python 
Python :: how to access specific index of matrix in python 
Python :: lxml etree fromstring find 
Python :: Flask application displaying list of items from SQL database as text 
Python :: python pyramid pattern 
Python :: How to solve import errors while trying to deploy Flask using WSGI on Apache2 
Python :: variable bound to set python 
Python :: extracting code blocks from Markdown 
Python :: python json string indices must be integersAdd Answer 
Python :: pandas maxima and minima for given column 
Python :: ring Copy Lists 
Python :: how to enter tavble in sal through sql 
Python :: list slicing 
Python :: how to start spaCy code 
Python :: python quick tutorial 
Python :: weigted average in pandas 
Python :: consider a string note: "welcome" statment will rais error 
Python :: colorgram.py 1.2.0 
Python :: how to threshold filter geodataframe by column value 
Python :: how to multiply integer value with float values in python 
Python :: discord.py reply to message 
Python :: delete all historical data django simple history 
Python :: add suffix to multiple file names python 
Python :: convert numpy array to byteslist 
Python :: Aminul 
Python :: django create superuser with first_name 
Python :: remove exif from image 
ADD CONTENT
Topic
Content
Source link
Name
6+5 =