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:
RegExp that disables smileys in [code]

 



yapp
User

Feb 12, 2002, 3:26 AM

Post #1 of 6 (6432 views)
RegExp that disables smileys in [code] Can't Post

Hello there. Good to be back to this great forum!

I want to solvde a problem in my forum's BBC processing code. All BBC codes are processed and converted correctly using my parser. Between [code] and [/code] the BBC codes aren't processed. This works fine.

Now, I also don't want any smileys, like :) ::) ;) 8:-) >:-) being replaced by my BBC processer, when they are used between [code] tags.

Does anyone know what kind of regexp can test for this. My current regexp replaces all occurences, not watching out for [code] tags.

Yet Another Perl Programmer

_________________________________
~~> [url=http://www.codingdomain.com]www.codingdomain.com <~~
More then 3500 X-Forum [url=http://www.codingdomain.com/cgi-perl/downloads/x-forum]Downloads! Cool


AndyNewby
Novice

Feb 12, 2002, 4:02 AM

Post #2 of 6 (6428 views)
Re: [yapp] RegExp that disables smileys in [code] [In reply to] Can't Post

We need a bit more information really to be able to help you more. E.g. the name of the variable, any existing regex that surrounds it etc. Also, the part that processes the smilies normally would be helpful. That way we may be able to just edit that so it only processes smilies outside [code] tags.

Andy
webmaster@ace-installer.com
http://www.ace-installer.com


Paul
Enthusiast

Feb 12, 2002, 4:21 AM

Post #3 of 6 (6426 views)
Re: [yapp] RegExp that disables smileys in [code] [In reply to] Can't Post

Hi,

if there is a common character in the smileys such as ( or ) then you could convert them to their ascii equivalent before the code tags are parsed so it will skip over them.

I can't remember the ascii values of the top of my head but < for example is &lt;


PerlKid
stranger

Feb 12, 2002, 4:29 AM

Post #4 of 6 (6423 views)
Re: [RedRum] RegExp that disables smileys in [code] [In reply to] Can't Post

hehe.. ascii values are numerical Laugh &lt; is a named character Paul.
--Philip
FuzzyLogic at PerlMad dot com


Paul
Enthusiast

Feb 12, 2002, 4:34 AM

Post #5 of 6 (6422 views)
Re: [PerlKid] RegExp that disables smileys in [code] [In reply to] Can't Post

Well if we are being totally correct it is an entity name but it is just another way of writing the actual ascii value.

Anyway for parentheses you'll need:

&#040; or &lpar;

and

&#041; or &rpar;


(This post was edited by RedRum on Feb 12, 2002, 4:37 AM)


yapp
User

Feb 12, 2002, 10:31 AM

Post #6 of 6 (6409 views)
Re: [RedRum] RegExp that disables smileys in [code] [In reply to] Can't Post

I thought that doesn't matter, and explained enough about the content..
However, here it comes:

- All smileys are stored in a hash.
%Smileys = ( qq|:)| => 'happy', qq|;)|, 'wink', qq|;D| => 'grin');
- The values will be replaced by <IMG src="/images/smileys/$value.gif"> before the function starts.
- The smiley replacement function iterates through the hash, sorted at the length of the smiley. So the rolleyes ::) get's converted before :)
- Then replace it.
while(my $smiley = shift @sorted) {
$message =~ s/\Q$smiley/$Smileys{$smiley}/gi;
}

ps. If you need the exact details, let me know, because I don't want to copy-paste code right now from my files stored at another computer in my home network.

(sorry I replies to RedNum], I ment the post before it, but I'm watching from flat view)

Yet Another Perl Programmer

_________________________________
~~> [url=http://www.codingdomain.com]www.codingdomain.com <~~
More then 3500 X-Forum [url=http://www.codingdomain.com/cgi-perl/downloads/x-forum]Downloads! Cool

(This post was edited by yapp on Feb 12, 2002, 10:32 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