0
Can someone help me with this problem of regex?
City Social Club issues its membership id in a special format: [LastName initial][FirstName initial][date of birth]-[date of month][gender]- followed by 5 digited number. Eg: Member name: Stephen Marak, Data of birth: 3rd April 1987 gender: Male Member Id :MS03-04M-87256 Here last five digital figures are random number generated. Design a Regex to match the membership id.
4 ответов
+ 3
import re
mname=re.compile(r'Member name:\s?(\w+)\s?(\w+)')
date=re.compile(r'Data of birth:\s?(\d+\w+)\s?(\w+)\s?(\d{4})')
sex=re.compile(r'gender:\s(Male|Female)')
sexual=re.findall (sex,F)
birth=re.findall(date,F)
name=re.findall(mname,F)
print (name )
print(birth )
print(sexual )
+ 1
Please post your question just once. Thank you
+ 1
Thanks Amir
0
looks like a homework assignment to me(but not sure) because you can achieve the same result with just simple string operations and no Regex.
If suppose this is for the purpose of learning Regex then just learning 2 pages on regex would surely help solve this on your own because this examples are usually being covered on teaching of basic regexs.
And also very important "where is your attempt?"