Re: Extracting values from a regex match Programming Software Development by Tom_45 Question has been answered. The correct pattern is: matches = re.findall(r'<td>(\d+)+<\/td><td>(\w+)<\/td><td>(\w+)', file) Extracting values from a regex match Programming Software Development by Tom_45 …>Raquel</td> I am using the pattern match = re.findall(r'<td.?>([\d+])([.?])*<\/td>… Why am getting different syntax errors when running a Python script Programming Software Development by Tom_45 …><td>(\w+)', file) for match in matches: #print(match) rank = match[0] name = match[1] item = (year, name, rank)… names.append(item) #print(item) name = match[2] item = (year, name, rank) names.append(item) #print(item… Re: Extracting values from capturing groups in regex Programming Software Development by AndreRet … an expression with repetitions will attempt to match as many characters as possible. The asterisk…metacharacters exhibit 'repetitious' behavior, and attempt to match as many instances as possible.) Your code …(html_data) for match in matches: print(f'({match[0]}, "{match[1]}", "{match[2]}")') This… Converting PDF Image to CSV Using Multimodal Google Gemini Pro Programming Computer Science by usmanmalik57 … = "TEMP_CURRENCY" currency_matches = special_patterns.findall(line) for match in currency_matches: line = line.replace(match, temp_replacement, 1) parts = line.split(',') for i… PDF Image Table Extractor Web App with Google Gemini Pro and Streamlit Programming Computer Science by usmanmalik57 … = "TEMP_CURRENCY" currency_matches = special_patterns.findall(line) for match in currency_matches: line = line.replace(match, temp_replacement, 1) parts = line.split(',') for i… Track Faces from Videos with Margins Using Deep Learning in Python Programming Computer Science by usmanmalik57 … increases the width and height of the smaller frames to match the largest frame. We will pass the list of frame… Extracting values from capturing groups in regex Programming Software Development by Tom_45 …>Raquel</td> I am using the pattern match = re.findall(r'<td.*?>([\d+])([.*?])*<\/td>… Re: Extracting values from capturing groups in regex Programming Software Development by Reverend Jim … return only ['236', 'Roy', 'Allyson'] The expression `.+?` does a lazy match (returns the shortest possible string that matches the pattern. Re: Extracting values from a regex match Programming Software Development by Reverend Jim The trick is to use lazy matching which matches the shortest possible string. html = '<tr align="right"><td>236</td><td>Roy</td><td>Allyson</td>' pat = '<td>(.+?)</td>' then re.split(pat,html) returns ['<tr align="right">', '236', … Re: Extracting values from a regex match Programming Software Development by pritaeas Sidenote: If you want to learn, understand and experiment with regexes I can highly recommend RegexBuddy. Re: Extracting values from a regex match Programming Software Development by Reverend Jim Also [autoregex](https://www.autoregex.xyz/) Re: Extracting values from a regex match Programming Software Development by AndreRet Same question, different post - [Extracting values from capturing groups in rege](https://www.daniweb.com/programming/software-development/threads/541420/extracting-values-from-capturing-groups-in-regex) Re: Why am getting different syntax errors when running a Python script Programming Software Development by Tom_45 After I posted this question I noticed that I was missing the raw string indicator and the capture group enclosing parenthesis on the findall, which explains the subscripting error. So, hold off on the answers for now. I'm still having other issues with multiple file runs, though. Re: Why am getting different syntax errors when running a Python script Programming Software Development by Tom_45 Finished the assignment and was able to work out the bugs I was encountering. In addition to the issues I mentioned in my last reply, I had several instances of not indenting properly so that statements like exit() were not executing because their indention made them part of an if statement. Re: Track Faces from Videos with Margins Using Deep Learning in Python Programming Computer Science by EdwardMatthew It's fantastic, I have read this article and it is super amazing. thankyou for the knowledge. Re: Extracting values from capturing groups in regex Programming Software Development by Tom_45 I'm not getting the results you presented, I'm getting the whole file not just the tr tags. The tr tags I used was just a subset of the entire file. Re: Extracting values from capturing groups in regex Programming Software Development by Reverend Jim Just process the file line by line and apply the regular expression to particular lines. I can't give you an expression that matches only the lines you showed me with a guarantee that in matches nothing else without seeing the entire file. Re: Extracting values from capturing groups in regex Programming Software Development by Reverend Jim You can either read the entire file into a list, then filter that list, or you could process it line by line and process each matching line. For example (using my file) for line in open('usblog.txt'): if '2024-01-24' in line: print(line) or text = open('usblog.txt').readlines() for line in [x for x in text if… Re: Extracting values from capturing groups in regex Programming Software Development by Tom_45 It's a long one, but here it is. <head><title>Popular Baby Names</title> <meta name="dc.language" scheme="ISO639-2" content="eng"> <meta name="dc.creator" content="OACT"> <meta name="lead_content_manager" content="JeffK"&… Re: Extracting values from capturing groups in regex Programming Software Development by Reverend Jim Try import re pat = '<td>(.+?)</td>' for line in open('yourfile.html'): if line.startswith('<tr align="right"><td>'): print(re.findall(pat,line)) I realized that findall is cleaner than split. You might want to have a look at [this regex online tool](https://www… Re: Extracting values from capturing groups in regex Programming Software Development by Tom_45 Issue resolved Re: Change-a-Letter-or-Two-Game Community Center Geeks' Lounge by christina>you match Re: Very simple regular expression question .? Programming Software Development by vegaseat match() is for the beginning of a string search() looks through the entire string Re: Image Matching Programming Software Development by tong1 Match in size (the same width and height) or Match in the ratio of width over height, or by other criteria? Re: Confirmation links creation Programming Web Development by almostbob … code and name has to [LIST][*]exist in the database [*]match [*]come from the same [icode]$_server['remote_addr'][/icode] as the… Re: Word Association Game Community Center Geeks' Lounge by szukalski match --> zippo Re: Wierd error messages with calculator program Programming Software Development by Dave Sinkula Match each [FONT=Courier New]{[/FONT] to its [FONT=Courier New]}[/… Re: so I find myself here again Programming Software Development by Joatmon match the brackets, notice that you are closing the function on line 11 without returning any value. Re: <HELP> Monitors goes on and off repeatedly Hardware and Software Hardware by dogbreath077 Match the output of your video card to the settings of your monitor.