Parsing Digits in Strings, using RE

William Cellich William.Cellich at lydiandata.com
Mon Jun 26 22:01:30 CEST 2006


Hello, all. I am using a regular expression 

 

XXX_re = re.compile( ' \ d { 12 } ' )          # spaces added for
clarity

 

that returns the value below from a string similar to this one:

 

XX(00000000)

XXXXXXXXX[("XXX_XXX=123456789000","XXXXXX_XXX=1","Xxxxxxx=ABCDE01","Xxxx
xxxxxxxx=ABCDEF","XxxxXxxxx=987654321000")]

 

 

123456789000

987654321000

 

I only want "ONE" occurrence, the first one in the RE. The string pieces
are 12 digits.

 

I have tried prefacing the pattern with the ' XXX_XXX = ' string
segment, then I get 

 

XXX_XXX = 123456789000

 

 

When I use non-greedy ? or ., I get errors such as unscriptable, or
other.

 

Any suggestions??? 

 

I am able to do this as two separate progs, but have been unsuccessful
at getting it all together as a one-pass code.

 

Thanks!

 

William

 

 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20060626/0d4da7ed/attachment.html>


More information about the Python-list mailing list