Emanuel has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w use strict; my $source = <<EOF; [link title:Google]http://www.google.com[/link] [link title:Altavista]http://www.altavista.com[/link] [link title:perlmonks]http://www.perlmonks.com[/link] [link title:and now something completely different]http://www.perlmonk +s.com/index.pl?node_id=104944[/link] EOF my ($complete,$title,$url); while ($source =~ /(\[link title:(.*?)\](.*?)\[\/link])/gi) { $complete = $1; $title = $2; $url = $3; print "complete: $1\ntitle: $title\nurl: $url\n"; $source =~ s/$complete/<a href='$url'>$title<\/a>/g || print " +regex failed\n"; } print $source."\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: replacing variable in regex - probs with special chars?
by dragonchild (Archbishop) on Jan 30, 2003 at 18:24 UTC | |
by Emanuel (Pilgrim) on Jan 30, 2003 at 18:47 UTC | |
by jmuhlich (Acolyte) on Jan 30, 2003 at 20:11 UTC | |
by jmuhlich (Acolyte) on Jan 30, 2003 at 20:16 UTC | |
|
Re: replacing variable in regex - probs with special chars?
by fletcher_the_dog (Friar) on Jan 30, 2003 at 20:13 UTC | |
|
Re: replacing variable in regex - probs with special chars?
by integral (Hermit) on Jan 31, 2003 at 07:43 UTC | |
|
Re: replacing variable in regex - probs with special chars?
by clairudjinn (Beadle) on Jan 31, 2003 at 08:04 UTC | |
by Emanuel (Pilgrim) on Feb 03, 2003 at 03:29 UTC |