Questions tagged [findall]

Finds all matching sub-elements, by tag name or path. Many questions use this tag to refer to the python regular expression findall. https://docs.python.org/3/library/re.html Use the tag prolog-findall if the question relates to the Prolog findall/3 predicate.

FindAll is a method or operation that returns all of the items that meet the specified criteria.

853 questions
-2
votes
1 answer

How can I get all data via doctrine except one?

I am getting data via doctrine: $pages = $this->getDoctrine()->getRepository(Pages::class)->findAll(); What I want to to is get all data, except the data with the slug cat So I trying to achieve something like this: $pages =…
peace_love
  • 6,229
  • 11
  • 69
  • 157
-2
votes
1 answer

python regex need help to enumerate data

I want to enumerate '4.9.8' from this line. how can i get that. i am new in Regex. import re url = 'http://variety.com' line = "" regex =…
Shivam Raj
  • 137
  • 1
  • 11
-2
votes
1 answer

Python, regex - retrieve keywords from strings within dictionary

I have a dictionary with long strings as keys and sets as values. I also have a list of keywords. For example, dict1 = {"This is the long key with 9 in it.": {'value1'}, 'I have another long string with 4 and keyword': {'value2'}} list_of_keywords…
JRR
  • 578
  • 5
  • 21
-2
votes
1 answer

Converting 4-digit year format to Python MM/DD/YYYY date time format

I used regex .findall(' ') function to extract date time elements of different formats from strings within a pandas data frame to 'list' objects and made them into a new column named "new." However, there are date time list objects that only of…
Chris T.
  • 1,699
  • 7
  • 23
  • 45
-2
votes
1 answer

Why the regex with re.findall() doesn't work?

I tried to extract the text from a html code. And here's my code: import re Luna = open('D:\Python\Luna.txt','r+') text=Luna.read() txt=re.findall('

\s+(.*)

',text) print txt However, it only eliminate the part before the first

and…

Hang Lin
  • 51
  • 4
-2
votes
1 answer

Iterate over a list of strings in python

I am trying to set up a data set that checks how often several different names are mentioned in a list of articles. So for each article, I want to know how often nameA, nameB and so forth are mentioned. However, I have troubles with iterating over…
M.Metz
  • 1
  • 1
  • 2
-2
votes
2 answers

Python : Regex capturing genric for 3 cases.

Hi Anyone help me imporve my not working regular expresion. Strings Cases: 1) 120 lbs and is intended for riders ages 8 years and up. #catch : 8 years and up 2) 56w x 28d x 32h inches recommended for hobbyists recommended for ages 12 and up.…
The Gr8 Adakron
  • 1,200
  • 1
  • 12
  • 15
-2
votes
2 answers

python .findall results into readable

Need some help sorting the results from .findall in python to convert the results in some readable format. I have a snippet giving me following output [('Jul 11 11:25:51', 'ul 11 11:25:51', '', '', ''), ('', '', 'u2k', '', ''), ('', '', '',…
Saadi381
  • 55
  • 1
  • 2
  • 9
-2
votes
2 answers

Parsing a tag in HTML

I know that the question has been asked but I think not in this specific situation. If it's the case feel free to show me the case. I have a HTML file hierarchized (you can view the original here) that way :
Title 1
Le Duc Banal
  • 53
  • 11
-2
votes
3 answers

Regex - Python - Capture everything between a word

Is it possible to capture specific sentences that contain as a keyword (time)? example: `I want to capture this part (time) and this part. Not this sentence though because it does not contain our keyword. But also this sentence because it contains…
D1W1TR15
  • 99
  • 2
  • 11
-2
votes
2 answers

Python regular expression findall *

I am not able to understand the following code behavior. >>> import re >>> text = 'been' >>> r = re.compile(r'b(e)*') >>> r.search(text).group() 'bee' #makes sense >>> r.findall(text) ['e'] #makes no sense I read some already existing question and…
-2
votes
4 answers

How can I use regex in Python to return these numbers?

I have the following code stored as a string variable in Python. How can I use regex, along with re.findall('', text), to parse out the five 9-digit numbers (all starting with "305...") under "attributeLookup" lookup in the below code? var…
user994585
  • 661
  • 3
  • 13
  • 28
-2
votes
2 answers

Why is python automatically putting a \ infront of '?

Pretty much as question states- I have a code that finds sentences in a big string using regex- findall(). It then uses this sentence later, however when it uses it it puts a backslash infront of any apostrophe, for example Today's becomes…
user3662991
  • 1,083
  • 1
  • 11
  • 11
-2
votes
1 answer

python expression not working

I am currently trying to extract data from a file I read: with open(_args.file, 'ru') as _fpInput: # Remove empty lines lines = [l for l in _fpInput if(l[:-1])] # Process special characters clean = ''.join(lines) clean =…
Francisco
  • 519
  • 1
  • 5
  • 15
-2
votes
2 answers

How to find out which word matched?

I've a pattern to find some words etc in a string. Here is my code: pattern = { "eval\(.*\)", "hello", "my word" } patterns = "|" . join( pattern ) patterns = "(^.*?(" + patterns + ").*?$)" code =…
user3507915
  • 279
  • 3
  • 15
1 2 3
56
57