CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Regular Expressions:
Nested tags

 



RussianSpy
Novice

Oct 22, 2007, 10:59 AM

Post #1 of 7 (3724 views)
Nested tags Can't Post

Hi, I want to take a string like


Code
 one 

Quote
two

Quote
three bold


four



and end up with


Code
  

one [someText] four [someText] six



but everything i tried so far with regex either stops and the first closing

tag, or starts with the last opening

Quote
tag :(

how can I do this?
_________________________________________________
[ noobie alert ] WinXP :: Xitami Webserver :: Active Perl 5.8.6


KevinR
Veteran


Oct 22, 2007, 12:30 PM

Post #2 of 7 (3723 views)
Re: [RussianSpy] Nested tags [In reply to] Can't Post

I don't understand your question
-------------------------------------------------


RussianSpy
Novice

Oct 22, 2007, 1:20 PM

Post #3 of 7 (3721 views)
Re: [KevinR] Nested tags [In reply to] Can't Post

oops, sorry, i didn't realize it will interpret my tags inside CODE tag, many forum engines dont'...

i basically need to convert

start [tag] text inside [tag] text inside nexted tag [/tag] more text [/tag] middle [tag] tagged text [/tag] the end

to

start [description] middle [description] the end
_________________________________________________
[ noobie alert ] WinXP :: Xitami Webserver :: Active Perl 5.8.6


KevinR
Veteran


Oct 22, 2007, 2:21 PM

Post #4 of 7 (3718 views)
Re: [RussianSpy] Nested tags [In reply to] Can't Post

I am not good with psuedo data, are those HTML tags or something else? Can you post an example of the real data?
-------------------------------------------------


RussianSpy
Novice

Oct 22, 2007, 2:51 PM

Post #5 of 7 (3716 views)
Re: [KevinR] Nested tags [In reply to] Can't Post

i did in the first post :) -- its BB codes. basically chage TAG to QUOTE in my last post (this board renders it, so i can't post it here) - that is real example, and "[description]" can be any text, i use "

Quote
", but it could be "*qote*", "QUOTE", "=anytext=", ... whatever.

i'm listing latest posts (subject + first 200 chars) from my phpBB forum on my home page, and strip BB tags from it, but when people replying to a quote i want to indicate that there is a quote. of course people keep hitting "quote" button creating nested quotes, some of them 4-5 levels deep. i don't what to just strip quote tags and leave quote's text cause first 200 chars will the the text of the quote almost always, and on the from page i'll have the list of the same replys :-/

obviously this isn't very important project :) but i'm just very curious cause I can't find a solution with regex (im not very good at it too :)). i could probably do something without regex, with loops, counting levels, but I can't believe its not possible with regex..

thanks
_________________________________________________
[ noobie alert ] WinXP :: Xitami Webserver :: Active Perl 5.8.6


KevinR
Veteran


Oct 22, 2007, 9:13 PM

Post #6 of 7 (3714 views)
Re: [RussianSpy] Nested tags [In reply to] Can't Post

It might be possible with just using a regexp, but it sounds like the wrong tool for the job. Besides, since you are using a php powered BB I am not sure why you aasking on a perl forum. I would ask on a forum dedicated to that particular bulletin board. Maybe someone has already done something similar.
-------------------------------------------------


RussianSpy
Novice

Oct 23, 2007, 7:22 AM

Post #7 of 7 (3712 views)
Re: [KevinR] Nested tags [In reply to] Can't Post

my website is not on php, only the forum is. and everything similar that already exists (from what i found) only displays titles/subjects or simply strips tags from the body.
_________________________________________________
[ noobie alert ] WinXP :: Xitami Webserver :: Active Perl 5.8.6

(This post was edited by RussianSpy on Oct 23, 2007, 7:28 AM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives