Need help with re for matching and getting the value python

Posted by laspal on Stack Overflow See other posts from Stack Overflow or by laspal
Published on 2010-03-21T06:10:35Z Indexed on 2010/03/21 6:11 UTC
Read the original article Hit count: 273

Filed under:

Hi, Need help regarding re.

file =  'file No.WR79050107006 from files'

So what I am trying to do is validate if file string contains WR + 11 digit.

result = re.match('^(\S| )*(?P<sr>(\d){11})(\S| )*', file)

Its validate only 11 digit but not WR before it. How can I do that?

Using re after matching how can I get the match value ( WR79050107006)

I can do string find

index = file.find('file No.')

and then get the value of next 13 char.

thanks

© Stack Overflow or respective owner

Related posts about python