in reply to capture psudo tags

First, I agree, it's probably a bad idea to parse your own pseudo-html tags.

I will note, however, that the main problem I see in this regex is the unescaped front slashes, "/", which should be written "\/" when they're inside the regex. Also (correct me if I'm wrong I'm not so good at regex myself), doesn't * include 0 instances of a character, making the ? unnecessary?

LassiLantar

Replies are listed 'Best First'.
Re^2: capture psudo tags
by Eimi Metamorphoumai (Deacon) on Jul 23, 2004 at 17:41 UTC
    Or you could use something other than / for your delimiters, if you're going to have a lot of slashes in your patterns. For instance,
    $text =~ s!(.*?)<link=(".*?")>(.*?)</link>!$1<a ref=$2>$3</a>!gi;
    would work. Additionally, there's no need for the first match, so it could just be
    $text =~ s!<link=(".*?")>(.*?)</link>!<a ref=$2>$3</a>!gi;
    As for the ?, it is meaningful. *? is a non-greedy match. But in general, I agree with the others that the whole attempt could be an interesting playpen for learning, but really shouldn't be attempted seriously.