Splitting a string every 'n'

Huaiyu Zhu huaiyu at gauss.almadan.ibm.com
Tue Jul 9 17:45:45 EDT 2002


Skip Montanaro <skip at pobox.com> wrote:
>
>    Huaiyu> To work with any int n, change to one of these
>
>    Huaiyu> rex = re.compile('.{,%s}'%n, re.DOTALL)  # keeps remainder segment
>
>I think you want {1,%s}.  Note the spurious empty string at the end if at
>least one character isn't required:

Yes, you're right.  Teaches me to test before post.

Huaiyu



More information about the Python-list mailing list