in reply to Whats your favorite nonstandard regex quote char?

I tend to favor either ! or |. Occasionally I'll use ' as well. As for a reason, I dunno...it looks good.
s'{.*?}'{$sub[$n++]}'g; s|{.*?}|{$sub[$n++]}|g;

Replies are listed 'Best First'.
Re: Re: Whats your favorite nonstandard regex quote char?
by BrowserUk (Patriarch) on Apr 22, 2003 at 21:45 UTC

    A word of caution re: using ' as a regex delimiter, if the regex includes vars that you want interpreted, the regex won't do what you want when you use 's--as in this case for instance.

    $s ='25 {fred and barney} text 2.36 12.0 {bam bam} text {pebbles}'; $n=0; $s =~ s'{.*?}'{$sub[$n++]}'g; print $s; 25 {$sub[$n++]} text 2.36 12.0 {$sub[$n++]} text {$sub[$n++]}

    Examine what is said, not who speaks.
    1) When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong.
    2) The only way of discovering the limits of the possible is to venture a little way past them into the impossible
    3) Any sufficiently advanced technology is indistinguishable from magic.
    Arthur C. Clarke.
      Ooh! Thank you for pointing out that caveat. It will no doubt someday save me hours of debugging time. ;-)
Re: Re: Whats your favorite nonstandard regex quote char?
by RMGir (Prior) on Apr 22, 2003 at 18:11 UTC
    ', sure, but |? (Ok, that sentence needs work:))

    I'd shy away from metacharacters; at first glance, it's hard to tell you're not starting an alternative rather than starting the right side.
    --
    Mike

      It just looks clean to me, especially since it spans the height of the whole line. In my editor, it stands out quite nicely, so that isn't a problem for me. If it does start to get confusing though, I will use a different character.