I am trying to extract duration using regex,
Example text,
text = "Google, Inc 09/19 - 09/20 CA, USA"
Here, is the regex I have,
pattern = fr"""
(?:
(
\d\d(?:\.|\/)\d\d\d\d|
(?:{months_abr})?
(?:{months_exp})?
(?:
(?:[\s\.\/\-]?\d{{2,4}})
)
)\s*(?:\-|to|\s)\s*
(
\d\d(?:\.|\/)\d\d\d\d|
(?:{months_abr})?
(?:{months_exp})?
(?:
(?:[\s\.\/\-]?\d{{2,4}})
)|
current|present|till\s?\-?date|till\s?\-?now|till\s?\-?date|to\s\-?present|until\s?\-?now|till\s?\-?now
)
)"""
find_all = re.findall(
pattern, text, flags=re.MULTILINE | re.VERBOSE | re.IGNORECASE
)
The output I am getting,
[('/19', '09')]