[REBOL] Re: Little parsing problem just got bigger

2000-11-22 Thread Andrew Martin

> Except for the fact that that code contains $'s, []'s, ()'s, and {}'s, I'd
say put all of ikoncode into a block and parse the whole block.

Hmmm, a Perl to Rebol translator...

Andrew Martin
Who's way too little time to work on it.
ICQ: 26227169
http://members.nbci.com/AndrewMartin/
-><-


-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.




[REBOL] Re: Little parsing problem just got bigger

2000-11-21 Thread chaz

Except for the fact that that code contains $'s, []'s, ()'s, and {}'s, I'd
say put all of ikoncode into a block and parse the whole block.

Something like 

substituteblock: copy []
parse ikoncode [
any [thru "^$post =~ s/" original to "/" thru "/" copy substitute to "/"]
( comment{replacement code} )
]





At 04:30 PM 11/20/00 -, you wrote:
>Thanks to all those that helped solve/explain the parsing problem I needed
>help with. I managed to get that all working fine.
>
>However (there's always a however isn't there?)...
>The problem runs a little deeper than I thought.
>
>I'm writing a small add on to a bbs written in Perl to produce a 'Slash
>style' front page. The Perl bbs software allows the poster to add custom
>tags e.g. [color = xxx] [quote] [code] as well as interpreting www as an
>html link and adding a link etc. I thought there were only a few tags I had
>to worry about but on looking at the Perl code I find there are nearly 50
>cases to worry about.
>
>I've included the perl code below (appologies for posting so much non Rebol
>code - but it helps explain the problem). Basically what I need to do is
>mimic the Perl code below in Rebol. That way I can read the post with Rebol
>and display the post correctly.
>
>So I guess what I need is a general purpose function to replicate the Perl
>regular expression search and replace function.
>
> sub ikoncode {
>
>my $post = shift;
>
>$post =~ s/\//isg;
>$post =~ s|\[\[|\{\{|g;
>$post =~ s|\]\]|\}\}|g;
>$post =~ s|\n\[|\[|g;
>$post =~ s|\]\n|\]|g;
>$post =~ s|| |g;
>$post =~ s|\[hr\]\n|\|g;
>$post =~ s|\[hr\]|\|g;
>$post =~
>s/\[quote\](.*)\[quote\](.*)\[\/quote](.*)\[\/quote\]/size=\"1\" face=\"verdana, helvetica\">$1<\/font>size=\"1\" face=\"verdana, helvetica\">$2<\/font><\/blockquote>size=\"1\" face=\"verdana, helvetica\">$3<\/font><\/blockquote>/isg;
>$post =~ s/\[quote\]\s*(.*?)\s*\[\/quote\]/size=1>$1size=1><\/blockquote><\/font>/isg;
>$post =~ s/\[url\](\S+?)\[\/url\]/target=\"_blank\">$1<\/a>/isg;
>$post =~ s/\[url=http:\/\/(\S+?)\]/target=\"_blank\">/isg;
>$post =~ s/\[url=(\S+?)\]/target=\"_blank\">/isg;
>$post =~ s/\[\/url\]/<\/a>/isg;
>$post =~ s/\ http:\/\/(\S+?)\ / target=\"_blank\">http\:\/\/$1<\/a> /isg;
>$post =~ s/http:\/\/(\S+?)\ /target=\"_blank\">http\:\/\/$1<\/a> /isg;
>$post =~ s/^http:\/\/(\S+?)\ /target=\"_blank\">http\:\/\/$1<\/a> /isg;
>$post =~ s/\ www.(\S+?)\ / target=\"_blank\">http\:\/\/www.$1<\/a> /isg;
>$post =~ s/www.(\S+?)\ /target=\"_blank\">http\:\/\/www.$1<\/a> /isg;
>$post =~ s/^www.(\S+?)\ /target=\"_blank\">http\:\/\/www.$1<\/a> /isg;
>$post =~ s/\[b\]//isg;
>$post =~ s/\[\/b\]/<\/b>/isg;
>$post =~ s/\[i\]//isg;
>$post =~ s/\[\/i\]/<\/i>/isg;
>$post =~ s/\[size=\s*(.*?)\s*\]\s*(.*?)\s*\[\/size\]/size=\"$1\">$2<\/font>/isg;
>$post =~ s/\[font=\s*(.*?)\s*\]\s*(.*?)\s*\[\/font\]/face=\"$1\">$2<\/font>/isg;
>$post =~ s/\[u\]//isg;
>$post =~ s/\[br\]//isg;
>$post =~ s/\[\/u\]/<\/u>/isg;
>$post =~ s/\[img\](.+?)\[\/img\]//isg;
>$post =~ s/\[color=(\S+?)\]//isg;
>$post =~ s/\[\/color\]/<\/font>/isg;
>$post =~ s/\\http:\/\/(\S+)/target=\"_blank\">http:\/\/$1<\/a>/isg;
>$post =~ s/\[list\]//isg;
>$post =~ s/\[\*\]//isg;
>$post =~ s/\[\/list\]/<\/ul>/isg;
>$post =~ s/\[code\](.+?)\[\/code\]/face=\"Courier New\">code:<\/font>New\">$1<\/pre><\/font><\/blockquote>/isg;
>$post =~ s/\\(\S+?)\@(\S+)/mailto:$1\@$2\"\>$1\@$2<\/a>/ig;
>$post =~ s/\[email=(\S+?)\]/mailto:$1\">/isg;
>$post =~ s/\[\/email\]/<\/a>/isg;
>$post =~ s|\{\{|\[|g;
>$post =~ s|\}\}|\]|g;
>
>return $post;
>
>} # end routine
>
>
>-- 
>To unsubscribe from this list, please send an email to
>[EMAIL PROTECTED] with "unsubscribe" in the 
>subject, without the quotes.
>
>

-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.