Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python search string for word

import re

# Target String
target_string = "Emma is a baseball player who was born on June 17, 1993."

# find substring 'ball'
result = re.search(r"ball", target_string)

# Print matching substring
print(result.group())
# output 'ball'

# find exact word/substring surrounded by word boundary
result = re.search(r"ball", target_string)
if result:
    print(result)
# output None

# find word 'player'
result = re.search(r"player", target_string)
print(result.group())
# output 'player'
Comment

PREVIOUS NEXT
Code Example
Python :: run python script from c# 
Python :: window in python 
Python :: python install gimp 
Python :: how to change the title of a tkinter widnow 
Python :: how to sort list in descending order in python 
Python :: django password change view 
Python :: how to get the live website html in python 
Python :: open text file in python 
Python :: python define 2d table 
Python :: cvtcoloer opencv 
Python :: list count frequency python 
Python :: inverse matrice python 
Python :: pandas select data conditional 
Python :: flask console log 
Python :: find nan values in a column pandas 
Python :: change column value based on another column pandas 
Python :: show a image in python 
Python :: find null value for a particular column in dataframe 
Python :: pil image base64 
Python :: get current directory python 
Python :: replace value column by another if missing pandas 
Python :: how to pick a random number in a list python 
Python :: shift coordinate in python 
Python :: python emoji 
Python :: check django version 
Python :: read csv without index 
Python :: huggingface default cache dir 
Python :: python shuffle list with seed 
Python :: python control browse mouse selenium 
Python :: pygame.key.get_pressed() 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =