Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Python
Trouble splitting strings with consecutive delimiters
 

Index | Next | Previous | View Flat


deuteros at xrs

Apr 30, 2012, 9:50 PM


Views: 525
Permalink
Trouble splitting strings with consecutive delimiters

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")

Results in

['width', '150', '', 'height', '50', '', 'float', 'right']

Is there any way to avoid getting '' in my list without adding px; as a
delimiter?
--
http://mail.python.org/mailman/listinfo/python-list

Subject User Time
Trouble splitting strings with consecutive delimiters deuteros at xrs Apr 30, 2012, 9:50 PM
    Re: Trouble splitting strings with consecutive delimiters jpiitula at ling Apr 30, 2012, 11:14 PM
    Re: Trouble splitting strings with consecutive delimiters __peter__ at web May 1, 2012, 5:55 AM
    Re: Trouble splitting strings with consecutive delimiters steve+comp.lang.python at pearwood May 1, 2012, 8:12 AM
    Re: Trouble splitting strings with consecutive delimiters emile at fenx May 1, 2012, 10:06 AM
        Re: Trouble splitting strings with consecutive delimiters lamialily at cleverpun May 1, 2012, 10:13 AM
            Re: Trouble splitting strings with consecutive delimiters emile at fenx May 1, 2012, 10:36 AM
    Re: Trouble splitting strings with consecutive delimiters rustompmody at gmail May 1, 2012, 11:37 PM

  Index | Next | Previous | View Flat
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.