Python Regex after a known string -


i have string formatted such: | birth_date = 22 january 1898 |

i want write regex looks birth_date, , gets 4 digit sequence of digits after birth_date until pipe character

import re print re.sub(r'\d', '', "| birth_date = 22 january 1898 |") # output => 221898  # if want last 4 digits: print re.sub(r'(\d)', '', "| birth_date = 22 january 1898 |")[-4:] # output => 1898 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -