python - REGEX to make string start from specific point -
i have split string using regular expressions: nikolaus kopernikus -> 1473-1543
i tried following, gives me list without ->
what need years 1473-1543, preferably in list ['1473','1543']
import re print ( re.split(r'->', 'nikolaus kopernikus -> 1473-1543'))
i want regular expression makes string start specific sign, lot in advance!
if want use regular expression:
import re re.match('.*->[^\d]*(\d+)-(\d+)','nikolaus kopernikus -> 1473-1543').groups() #output: ('1473', '1543')
if need list instead of tuple use list
function.
Comments
Post a Comment