in reply to Call for code samples!

This is probably the nastiest regex I ever had to use. It's goal was to highlight Extended Letter Sequences in text. The ELS had already been found, this routine went through and turned the letters of the hidden word into uppercase. This is just a 'capitalise every nth letter' challenge, and I cheated by stripping out the spaces first:

#Block is the chunk of text, word is the 'hidden' word and sep is the +number of characters in the text between each word my ($block, $sep, $word)=@_; my @let = split //, $word; my $rep; my $i=1; foreach my $l (@let) {$l = "(".$l.")(.{$sep})";$rep.= + '\u$'.$i++.'$'.$i++;}; my $regexp2 = join "", @let; my $ev = '$block =~ '."s/$regexp2/$rep/i;"; # print "Now scanning block with $regexp2 and replacemen +t target $rep\n"; return $block, $word if eval $ev;

The output looks like this:

---This is the original text---------------------------------------- m at times; this thread, like that of Ariadne, when once unraveled will conduct one through a lab ---The ELS 'FNORD' is in capitals--------------------- mattimesthisthreadlikethatoFariadNewhenOnceunRaveleDwillconductonethro +ughalab

BTW if there's an obviously better way to do this I'd be delighted to hear about it.

____________________
Jeremy
I didn't believe in evil until I dated it.