This might be a duplicate, but I'm trying to replace all but a certain string pattern. Here is a sample of strings:
'dkas;6-17'
'dsajdl 10'
'dsjalkdj16-20'
The goal here is to replace anything that is not numbers-numbers with nothing. So what I'd get from the strings above are:
'6-17'
''
'16-20'
The second string would yield nothing because it didn't match the pattern. I know the regular expression to match my pattern, but I'm confused about how I'd use regexp_replace to match all but that pattern. The following is what I have, but this replaces the pattern I want to actually keep.
re.sub('[0-9]{1,2}\-[0-9]{1,2}', '', text)