findall

pandas findall re.ignorecase doesn't work

Pandas findall re.IGNORECASE doesn't work Question: I have a list of keywords: keywords = [‘fake’, ‘hoax’, ‘misleading’, etc.] I’d like to search the text column of DataFrame df1 for the above keywords and return rows containing these keywords (exact match), both in uppercase and lowercase (case-insensitive). I tried the following: df2 = df1[df1.text.apply(lambda x: any(i …

Total answers: 1

regex findall overlapped does not give match if one of them is a prefix of the other

regex findall overlapped does not give match if one of them is a prefix of the other Question: import regex product_detail = "yyy target1 target2 xxx".lower() p1 = r"btarget1b|btarget1 target2b" p2 = r"btarget2b|btarget1 target2b" for pattern in [p1, p2]: matches = regex.findall(pattern, product_detail, overlapped=True) print(matches) why does matches from p1 only give [‘target1’] as output, …

Total answers: 1

Get items from xml Python

Get items from xml Python Question: I have an xml in python, need to obtain the elements of the "Items" tag in an iterable list. I need get a iterable list from this XML, for example like it: Item 1: Bicycle, value $250, iva_tax: 50.30 Item 2: Skateboard, value $120, iva_tax: 25.0 <?xml version="1.0" encoding="UTF-8" …

Total answers: 1

Can overlapping matches with the same start position be found using regex?

Can overlapping matches with the same start position be found using regex? Question: I am looking for a regex or a regex flag in python/BigQuery that enables me to find overlapping occurrences. For example, I have the string 1.2.5.6.8.10.12 and I would like to extract: [1., 1.2., 1.2.5., 1.2.5.6., …, 1.2.5.6.8.10.12] I tried running the …

Total answers: 2

Return certain character or word followed or proceeded by space- Regex Python

Return certain character or word followed or proceeded by space- Regex Python Question: Try to select only the size of clothes using regex expression So I am new to Python and I trying to select rows find these sizes but gets confused with other words. I using regex expression but failed to obtain the desired …

Total answers: 1

Extracting float or int number and substring from a string

Extracting float or int number and substring from a string Question: I’ve just learned regex in python3 and was trying to solve a problem. The problem is something like this: You have given a string where the first part is a float or integer number and the next part is a substring. You must split …

Total answers: 2

What would be the regex pattern for the following?

What would be the regex pattern for the following? Question: I have multiple regex strings in format:- Example: A=’AB.224-QW-2018′ B=’AB.876-5-LS-2018′ C=’AB.26-LS-18′ D=’AB-123-6-LS-2017′ E=’IA-Mb-22L-AB.224-QW-2018-IA-Mb-22L’ F=’ZX-ss-12L-AB-123-6-LS-2017-BC-22′ G=’AB.224-2018′ H=”AB.224/QW/2018′ I=”AB/224/2018′ J=’AB-10-HDB-231-NCLT-1-2017 AD-42-HH-2019′ K=”AB-1-HDB-NCLT-1-2016 AD-42-HH-2020′ L=’AB-1-HDB-NCLT-1-2016/(AD-42-HH-2020) I want a regex pattern to get the output for the numbers that occur after the alphabets(that appear at the start) as well …

Total answers: 2

How to filter tag without an attribute in find_all() function in Beautifulsoup?

How to filter tag without an attribute in find_all() function in Beautifulsoup? Question: Below are a simple html source code I’m working with <html> <head> <title>Welcome to the comments assignment from www.py4e.com</title> </head> <body> <h1>This file contains the actual data for your assignment – good luck!</h1> <table border="2"> <tr> <td>Name</td><td>Comments</td> </tr> <tr><td>Melodie</td><td><span class="comments">100</span></td></tr> <tr><td>Machaela</td><td><span class="comments">100</span></td></tr> …

Total answers: 3

I can't get values page by page with for-in-loop

I can't get values page by page with for-in-loop Question: As title,I could get the values in just first page, but I can’t get values page by page with for-in-loop. I’ve chek my code, but I’m still confused with it. How could I get that values in every page? # Imports Required !pip install selenium …

Total answers: 2

How To Use FindAll While Web Scraping

How To Use FindAll While Web Scraping Question: I want to scrape https://www.ebay.co.uk/sch/i.html?_from=R40&_sacat=0&_nkw=xbox&_pgn=2&_skc=50&rt=nc and get the tiles (Microsoft Xbox 360 E 250 GB Black Console, Microsoft Xbox One S 1TB Console White with 2 Wireless Controllers etc). In due course I want to feed the Python script different eBay URLS but for the sake of …

Total answers: 2