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: Beginner:
emotionicons part2

 



patrik
stranger

Jul 7, 2001, 6:08 PM

Post #1 of 3 (495 views)
emotionicons part2 Can't Post

Used this string (as posted below)
But it wont replase >:) and >:( with the right images.
It posts the :) with a > infront of it, why ??

Code:
$xline =~ s/>:\)/<img src=\"imgs\/ms\/6.gif\">/g;
Ive also tried:
$xline =~ s/\>:\)/<img src=\"imgs\/ms\/6.gif\">/g;

Thanx i advance
Patrik

Excuse the bad english
Im from Sweden ;)


mhx
Enthusiast / Moderator

Jul 8, 2001, 12:30 AM

Post #2 of 3 (490 views)
Re: emotionicons part2 [In reply to] Can't Post

I think that's because there's some line like

Code
$xline =~ s/:\)/<img src=\"imgs\/ms\/4.gif\">/g;

somewhere before in your script. This line replaces all occurrences of :) even if it occurs within a >:). There are now several ways to solve this problem. First, you can sort your search-and-replace lines in order of character length of the emoticons, starting with the longest. All other ways would require me to have a look on your set of emoticons. But you may try sorting first.

Did you know you can use different characters than / for quoting regexes? You can write

Code
$xline =~ s[:\)][<img src="imgs/ms/4.gif">]g;

or

Code
$xline =~ s!:\)!<img src="imgs/ms/4.gif">!g;

which will save you from escaping all those slashes in your pathnames.

Hope this helps.

-- Marcus



patrik
stranger

Jul 8, 2001, 1:21 AM

Post #3 of 3 (488 views)
Re: emotionicons part2 [In reply to] Can't Post

Thanx again, worked out fine =)

Have a nice summer all of U

Excuse the bad english
Im from Sweden ;)

 
 


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

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