Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python how to extract a string from another string

import re

text = 'gfgfdAAA1234ZZZuijjk'

m = re.search('AAA(.+?)ZZZ', text)
if m:
    found = m.group(1)

# found: 1234
Comment

python how to extract a string from another string

>>> s = 'gfgfdAAA1234ZZZuijjk'
>>> start = s.find('AAA') + 3
>>> end = s.find('ZZZ', start)
>>> s[start:end]
'1234'
Comment

PREVIOUS NEXT
Code Example
Python :: file storage django 
Python :: django authenticate with email 
Python :: append a dataframe to an empty dataframe 
Python :: python os get dir path 
Python :: lowercase python 
Python :: python captcha bypass 
Python :: replace pandas column values based on condition 
Python :: beautifulsoup get img alt 
Python :: remove item from list 
Python :: arrays python 
Python :: close a file python 
Python :: python library for downsampling a photo 
Python :: python os.remove permissionerror winerror 5 access is denied 
Python :: shrink colorbar matplotlib 
Python :: get particular columns from dataframe 
Python :: python ceiling division 
Python :: argparse positional arguments 
Python :: drf serializer general validate method 
Python :: stack program in python3 
Python :: convert sentence to words python 
Python :: datetime print the current time 
Python :: print to file python 
Python :: python print values inside request.POST 
Python :: python json check if key exist 
Python :: if equal to key return value python 
Python :: How to take multiple inputs in one line in python using split() 
Python :: how to turn on debug mode in flask 
Python :: python random uuid 
Python :: flask abort 
Python :: python dataframe appendisnt showing 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =