Re: Extracting values from capturing groups in regex Programming Software Development by Tom_45 Issue resolved 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 capturing groups in regex Programming Software Development by Tom_45 …;\/td>', file) The file is created with a read() statement. The output should look like (236, "Roy", "… Extracting values from a regex match Programming Software Development by Tom_45 …;\/td>', file) The file is created with a read() statement. The output should look like (236, "Roy", "… Why am getting different syntax errors when running a Python script Programming Software Development by Tom_45 …, rank) names.append(item) #print(item)` On the re.findall statement, the error message invalid escape sequence on \d, so I… 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: Extracting values from capturing groups in regex Programming Software Development by Reverend Jim For 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', '', 'Roy', '', 'Allyson', ''] and re.split(pat,html)[1::2] will … 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 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 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 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: 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: Extracting values from a regex match Programming Software Development by Reverend Jim Also [autoregex](https://www.autoregex.xyz/) Re: Extracting values from capturing groups in regex Programming Software Development by AndreRet Your main issue is with the way you're trying to capture the values inside the 'td' tags. Also, you should consider using non-greedy quantifiers - [Minimal or non-greedy quantifiers](Regular expressions are generally considered greedy because an expression with repetitions will attempt to match as many characters as possible. The asterisk (*), plus… 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) Problem with webpage connectivity Programming Web Development by swornavidhya_m Statement: Connection with server takes a long time and provides "… scientific or simple calculator Programming by Husnain_6 statement: write a code in which user first select what type … Re: Clears some fundamentals Programming Software Development by limaulime statement 1: assign memory location for variable x, now variable x contains "garbage" value. statement 2: assign value to variable x which is 34. Re: Conn Stmt Programming Software Development by jeniferandrews Statement is used when u have fixed query... eg: select * from … core query...this kind of querying should be avoided... Prepared Statement is used in case of dynamic data retrieval...i.e… our case we have only ?mark so no complications] Callable statement is used for procedure calling or function calling... i.e… Re: Database not being populated.... Programming Software Development by tigerxx ************************************** Statement statement1 = con.createStatement(); **************************************** here is the problem u hav to give the query inside createStatement() like Statement statement1 = con.createStatement(string); then it'll work Re: Help Please!! Programming Software Development by kvprajapati Statement is written incorrectly, pop = 4 * double pow(e, t); pow is a static method of java.lang.Math class and you have to write the statement as follows: pop = 4 * Math.pow(e,t); Re: display array element with passing value...no undesstand~help Programming Software Development by bobei89 statement 11th and 38th...i think that for some sort to arrange the value printed. But no understand how it work. Thx for reading my post Re: Generating a random number without repetition Programming Software Development by abhimanipal statement 20 is unnecessary. You are anyway setting/ ignoring the value of num in the if else block. UPDATE STATEMENT ERROR.vb.net Programming Software Development by timothy0726 …, con) <<<< error here.. syntax error.Update statement error mycmd.ExecuteNonQuery() pls help.. quantity unit, Category,Supplier and… "The method setInt(int, String) is undefined for the type Statement" Programming Web Development by grendel0 …(int, String) is undefined for the type Statement", also error occurs for setString. Any … rst=null; ResultSet rst1=null; Statement stmt=null; Statement stmt1=null; Statement stmt2=null; try{ String url="… rst=null; ResultSet rst1=null; Statement stmt=null; Statement stmt1=null; Statement stmt2=null; try{ String url="… No return statement-Simple Programming Software Development by xiangzhuang … getComparison() { // You must use an if..else statement in this method // If you would like to test…the same as "+wordTwo; } }[B]//no return statement[/B] public String getCompareLength() { // You must use… an if..else..else statement in this method if (wordOne.length()>wordTwo.length… Re: "The method setInt(int, String) is undefined for the type Statement" Programming Web Development by grendel0 … I hadn't even declared stm2 as a prepared statement, rather a redular statement! This fixed the error, I have to agree…