You are here: Re: How to list/find html tags in text « PHP Programming Language « IT news, forums, messages
Re: How to list/find html tags in text

Posted by Carramba on 06/14/05 01:36

have you tryed to put verything in string sertch and abort when the first
one found, return everyting before abort and research the rest of string?
hope you understand were Iam doing with that

On Mon, 13 Jun 2005 09:46:14 +0200, sindre hiåsen <sindrehi@c2i.net> wrote:

> Hi,
>
> What I try to do is to search a text for html tags.
>
> Why. Because I want to use nl2br on the text, but since this command add
> br instead of all /n it is not a nice thing to add t.x. a html list
> inside the text. Of course it is possible to add the list and remove all
> space between li tags, but this is not so readable to the writer.
>
> What I try to do is also to add nl only in the plain text and inside li
> and td tags. So in the li case I have to find <ul> and </ul> and <table
>> <tr> </tr> </table>
>
> I did find a nice regular expression at php.net:
> function ereg_MatchedHTMLTags($tagname) {
> return
> "^(.*)(<[ \\n\\r\\t]*$tagname(>|[^>]*>))(.*)(<[ \\n\\r\\t]*/[ \\n\\r\\t]*$tagname(>|[^>]*>))(.*)$";
> }
> wich result in this.
> // The following values will be held in $Matches
> //(marked values are unintended byproducts of the expression)
> // *[0] - the entire string ($Source).
> // [1] - everything before the opening tag
> // [2] - the opening tag, including all contents (i.e.
> everything between < and >)
> // *[3] - the opening tag from end of the tag name,
> // e.g. '<body bgcolor="#000000">' gives '
> bgcolor="#000000">'
> // [4] - the tag contents (everything between the opening and
> closing tag)
> // [5] - the complete closing tag.
> // *[6] - the closing tag from the end of the tag name
> // e.g. '</body invalid text>' gives ' invalid
> text>'
> // [7] - everything after the closing tag.
>
>
> Nice. But it if there is two similar html tags, it returns the last one,
> not the first.
>
> So someone that can set me on the track of how to accomplish my goals?
>
> Regards, Sindre



--

Thanx in advance
________________________
BTW. I know my english is not best in the word, so please stop bugging me
about my spelling. And yes Iam sorry you don't understand what I mean, but
there is no point to yell at me. Have a nice day.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация