Trouble splitting strings with consecutive delimiters
rusi
rustompmody at gmail.com
Wed May 2 02:37:07 EDT 2012
On May 1, 9:50 am, deuteros <deute... at 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', "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?
Are you parsing css?
If so have you tried things like cssutils http://cthedot.de/cssutils/?
[There are other such... And I dont know which is best...]
More information about the Python-list
mailing list