This is the regex I am using:
date = "1981-89"
date = re.findall(r'\d+', date)
if the date is 1981-89 this returns [1981],[89]. What do I add to the regex to ignore anything after the dash including the dash itself?
Thanks!
If you need to use regular expressions, use the first element of a match search:
re.match(r'(\d+)', date).group() # matching using parenthesis in regex
match or search rather than findall.findall to match. Never really understood the difference between match and search.
date.partition('-')[0]would be a lot more efficient than using Regex.re.findall(r'(\d+)-', date)will work.