File size: 591 Bytes
7d9e4d2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import re

def parse_duration(text):
    print(f"Testing text: '{text}'")
    if not text:
        return 0
    # Current regex
    match = re.search(r'(\d+)\s*min', text, re.IGNORECASE)
    if match:
        return int(match.group(1))
    
    # Proposed regex for "minutes = 11"
    match = re.search(r'minutes\s*=\s*(\d+)', text, re.IGNORECASE)
    if match:
        return int(match.group(1))
        
    return 0

text1 = "Approximate Completion Time in minutes = 11"
text2 = "Duration: 30 mins"

print(f"Result 1: {parse_duration(text1)}")
print(f"Result 2: {parse_duration(text2)}")