Regex pattern problem in python

Posted by mridang on Stack Overflow See other posts from Stack Overflow or by mridang
Published on 2010-04-13T19:04:56Z Indexed on 2010/04/13 19:43 UTC
Read the original article Hit count: 498

Filed under:
|

I need to extract parts of a string using regex in Python.

I'm good with basic regex but I'm terrible at lookarounds. I've shown two sample records below. The last big is always a currency field e.g. in the first one it is 4,76. In the second one it is 2,00. The second has an account number that is the pattern of \d{6}-\d{6}. Anything after that is the currency.

24.02 24.02VALINTATALO MEGAHERTSI4,76-
24.02 24.02DOE MRIDANG 157235-1234582,00-

Could you help me out with this regex? What I've written so far is given below but it considers everything after the 'dash' in the account number to be the currency.

.*?(\d\d\.\d\d)(.*?)\s*(?<!\d{6}-\d{6})(\d*,\d\d)

Thanks in advance

© Stack Overflow or respective owner

Related posts about python

Related posts about regex