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

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -