in reply to Converting custom mark-up to HTML
Yep! Read up on 'numbered match variables' in perlre. They can be used as in the following:
use strict; use warnings; while (<DATA>) { s/\[image=([\w\.]+)\]/<img src="$1">/; s/\[color=([\w#]+)\]/<font color="$1">/; s/\[link=([\w:\/\.]+)\]/<a class="my_link" href="$1">/; print; } __DATA__ Hey have a look at this [image=var.jpg] Insert a [color=#99CC99] [link=http://www.perlmonks.net] to the site
Be warned, though, that what you're attempting to do might not be the best way to achieve what it is that you're trying to achieve. Are there any closing tags available for your bracketed markup?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Converting custom mark-up to HTML
by bkiahg (Pilgrim) on Apr 19, 2004 at 17:48 UTC |