Motivated by @bobble bubble's encouragement, I propose this regex (polished up after bobble bubble's comment):
([0-9]+).{1,15}teaching|teaching.{1,15}?([0-9]+)
Given the proximity of "teaching" to the number of years this regex splits the match in two parts:
- "teaching" comes after number of year but in close reach (any character within 1 to 15 positions).
- "teaching" comes first; note
.{1,15}?; ? at the end is not greedy otherwise it would match also "1" in "experience: 17"
The drawback is it generates two groups. You can get rid of it using python as follows:
import re
s = "10+ years small business ownership, 10+ years sme consulting, 10+ years corporate/vocational business training, 8 years teaching experience, years of teaching experience: 17, 7+ years teaching/Corporate Training experience"
matches = re.findall(r"([0-9]+).{1,15}teaching|teaching.{1,15}?([0-9]+)", s)
matches = [int(x) if x != '' else int(y) for (x, y) in matches]
print(matches) # A list of teaching years as int
\b\d+\+?(?:,\s?\d+\+?)*(?= years teaching\b)? Or perhaps\b\d+\+?(?=(?:,\s?\d+\+?)* years teaching\b)if you want "17" and "7+" to be captured separately.