Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

regex findall

import re
# regex for finding mentions in a tweet
regex = r"(?<!RTs)@S+"
tweet = '@tony I am so over @got and @sarah is dead to me.'

# mentions = ['@tony', '@got', '@sarah'] 
mentions = re.findall(regex, tweet)
Comment

Python RegEx Findall – re.findall()

# A Python program to demonstrate working of findall()
import re

# A sample text string where regular expression is searched.
string = """Todays date is 27 , month is 05 and year is 2022"""

# A sample regular expression to find digits.
regex = 'd+'

match = re.findall(regex, string)
print(match)
Comment

PREVIOUS NEXT
Code Example
Python :: difference between generator and iterator in python 
Python :: corr pandas 
Python :: python subtract lists 
Python :: python loop list from last to first 
Python :: python wait for x seconds 
Python :: tkinter text blurry 
Python :: python file parent 
Python :: python printing to a file 
Python :: resto division python 
Python :: exclude index column pandas 
Python :: assert keyword python 
Python :: python delete text in text file 
Python :: Python Requests Library Get Method 
Python :: identify total number of iframes with Selenium 
Python :: scikit learn lda 
Python :: numpy round to int 
Python :: pandas groupby apply list 
Python :: how to close opencv window in python 
Python :: python get average of list 
Python :: numpy matrix power 
Python :: keyboard press pyautogui 
Python :: how to clean environment python 
Python :: how to convert fahrenheit to celsius in python 
Python :: make tkinter label and input 
Python :: np array to tuple 
Python :: urllib3 python 
Python :: Add Border to input Pysimplegui 
Python :: if __name__ == 
Python :: how to check if a input is an integer python 
Python :: simple secatter plot 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =