Re: Trouble splitting strings with consecutive delimiters

2012-05-02 Thread rusi
On May 1, 9:50 am, deuteros deute...@xrs.net wrote: I'm using regular expressions to split a string using multiple delimiters. But if two or more of my delimiters occur next to each other in the string, it puts an empty string in the resulting list. For example:         re.split(':|;|px',

Re: Trouble splitting strings with consecutive delimiters

2012-05-01 Thread Jussi Piitulainen
deuteros writes: I'm using regular expressions to split a string using multiple delimiters. But if two or more of my delimiters occur next to each other in the string, it puts an empty string in the resulting list. For example: re.split(':|;|px', width:150px;height:50px;float:right)

Re: Trouble splitting strings with consecutive delimiters

2012-05-01 Thread Peter Otten
deuteros wrote: I'm using regular expressions to split a string using multiple delimiters. But if two or more of my delimiters occur next to each other in the string, it puts an empty string in the resulting list. For example: re.split(':|;|px', width:150px;height:50px;float:right)

Re: Trouble splitting strings with consecutive delimiters

2012-05-01 Thread Steven D'Aprano
On Tue, 01 May 2012 04:50:48 +, deuteros wrote: I'm using regular expressions to split a string using multiple delimiters. But if two or more of my delimiters occur next to each other in the string, it puts an empty string in the resulting list. As I would expect. After all, there *is* an

Re: Trouble splitting strings with consecutive delimiters

2012-05-01 Thread Emile van Sebille
re.split(':|;|px', width:150px;height:50px;float:right) You could recognize that the delimiter you want to strip is in fact px; and not px in and of itself. So, try: re.split(':|px;', width:150px;height:50px;float:right) Emile -- http://mail.python.org/mailman/listinfo/python-list

Re: Trouble splitting strings with consecutive delimiters

2012-05-01 Thread Temia Eszteri
re.split(':|;|px', width:150px;height:50px;float:right) You could recognize that the delimiter you want to strip is in fact px; and not px in and of itself. So, try: re.split(':|px;', width:150px;height:50px;float:right) Emile That won't work at all outside of the example case. It'd choke

Re: Trouble splitting strings with consecutive delimiters

2012-05-01 Thread Emile van Sebille
On 5/1/2012 10:13 AM Temia Eszteri said... re.split(':|px;', width:150px;height:50px;float:right) Emile That won't work at all outside of the example case. It'd choke on any attribute seperator that didn't end in px. It would certainly choke on all delimeters that are not presented in the