in reply to automagic-HTML regex

s{(?mx: # Explicitly set /mx for this scope. This puts the modifiers right + up where they are being used instead of at the end of the regex. ^\[$ ((?s:.*?)) # Non-greedy match of multiple lines ^\]$ )}{ my $tmp = $1; $tmp =~ s{^([^\n]+)$}{<li>$1</li>}mg; # Added /m and fixed closing + bracket. Preferred [^\n] to . for explictness. "<ul>$tmp</ul>" }eg;

Replies are listed 'Best First'.
Re: Re: automagic-HTML regex
by Cody Pendant (Prior) on Jun 16, 2003 at 23:16 UTC
    Thanks all of you. I think sauoq gets top points for explaining where my thinking had gone wrong, but all of the solutions seemed fine.

    In case you're not familiar with this kind of magic-first-char syntax, by the way, it's used in the online message board WebCrossing.

    It's known as "quick-edit" and allows you to write

    this is i italic text
    or
    this is b bold text
    or
    this is > indented text
    in the textarea box, which saves time and is userfriendly for non-HTML people. I got so used to it I couldn't live without it and sometimes find myself doing it in other applications!

    I'm trying to "embrace and extend" the syntax for my own purposes. Theirs doesn't use multi-line syntax at all.



    “Every bit of code is either naturally related to the problem at hand, or else it's an accidental side effect of the fact that you happened to solve the problem using a digital computer.”
    M-J D