Thursday, June 28, 2012

Re: replace or regex

On 06/28/12 01:42, pakyazilim wrote:
> i have text ;
> *<ul>*
> <li>A
> <ul>
> <li>B</li>
> </ul>
> </li>
> *</ul>*
> *
> *
> *i want to remove first <ul> end for text end </ul> tag. *
> *how can i it?*

Depends on what you want to happen in various odd edge-cases:

- what happens if other tags surround the outside <ul> block like

<foo><ul><li>A<ul><li>b</li></ul></li></ul></foo>

- what happens if there's only an opening or closing <ul> tag but
not the other?

- what happens if the <ul> tag has attributes on it like

<ul class='foo'>...</ul>

- what happens if case differs?

<UL>...</Ul>

- what happens if there are superfluous spaces?

< ul > ... < / ul >

- do you want to remove the tags and keep the whitespace around
them, or do you want to condense the whitespace too?


You likely want either a regexp or two, or you want a full-blown
HTML parser.

-tkc


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment