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: Intermediate:
Action input between HTML tags

 



fds
Novice

Aug 31, 2010, 4:07 AM

Post #1 of 6 (1561 views)
Action input between HTML tags Can't Post

 
Hi, I have input from a form textarea. It could contain text and or html. What I'm trying to is define any html tag, and then do something with the input inside that specific tag.

Here's what I've done, but it dosn't work - I'm probably going about it all wrong.



Code
$txtin = "<b>Hello</b> 
My text and then the tagged input.
<sometag><b>aaaaa</b></sometag>";

#foreach $line (@txtin) {
for $txtin ($txtin) {
if (/<sometag>/ .. /<\/sometag>/) {
$txtin =~ s/</&#60;/g;
$txtin =~ s/>/&#62;/g;
}
else {$txtin}
}
print qq ~<html><head><title></title></head><body>~;

print "$txtin<br>";

print qq ~</div></body></html>~;

In this example I would want to keep everything as is, except between the "sometags".

Can anyone help on this please.
----------------------------------------------
fdsaadsfdsaf


tej.87g
Novice

Aug 31, 2010, 4:23 AM

Post #2 of 6 (1556 views)
Re: [Ted] Action input between HTML tags [In reply to] Can't Post

Check if this is working


Code
$txtin = "<b>Hello</b>  
My text and then the tagged input.
<sometag><b>aaaaa</b></sometag>";

while ($txtin=~m/<sometag>(*.?)<\/sometag>/g) {
$txtin =~ s/</&#60;/g;
$txtin =~ s/>/&#62;/g;

}



fds
Novice

Aug 31, 2010, 5:03 AM

Post #3 of 6 (1550 views)
Re: [tej.87g] Action input between HTML tags [In reply to] Can't Post

Gave it a try and it came back with this:


Code
Unknown verb pattern '.?' in regex; marked by  
<-- HERE in m/<sometag>(*.?) <-- HERE </sometag>/
at ......... line 11.

----------------------------------------------
fdsaadsfdsaf


Zhris
Enthusiast

Aug 31, 2010, 11:01 AM

Post #4 of 6 (1523 views)
Re: [Ted] Action input between HTML tags [In reply to] Can't Post

Hi, I haven't tested but I think tej meant to do (.*?) not (*.?).

Chris


fds
Novice

Aug 31, 2010, 1:21 PM

Post #5 of 6 (1509 views)
Re: [Zhris] Action input between HTML tags [In reply to] Can't Post

Hi, I'll have to test it later now, as I'm into hospital early tomorrow morning for an eye operation and will be out of action for a couple weeks.

I see what you mean though. Normally an asterisk has to be there, it's just difficult for me to see at the moment. Shoulda realized it earlier.

Edit:
Yes that was the problem. I get entities showing now. It's a start and I should be able to take it from here.

Thanks a lot guys - Ted
----------------------------------------------
fdsaadsfdsaf

(This post was edited by Ted on Aug 31, 2010, 1:57 PM)


Zhris
Enthusiast

Aug 31, 2010, 2:16 PM

Post #6 of 6 (1496 views)
Re: [Ted] Action input between HTML tags [In reply to] Can't Post

Get well soon :).

 
 


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

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