in reply to Whats your favorite nonstandard regex quote char?

It all depends on what I'm doing... If it's a script that I'll use more than once, I tend to lean towards readability. If it's an obfuscation, I go for confusion of course.

For what should be obvious reasons, these are some of my personal favorites:
s@{.*?}@{$sub[$n++]}@g;
s${.*?}${$sub[$n++]}$g;
s%{.*?}%{$sub[$n++]}%g;
s={.*?}={$sub[$n++]}=g;

Replies are listed 'Best First'.
Re: Re: Whats your favorite nonstandard regex quote char?
by demerphq (Chancellor) on Apr 22, 2003 at 15:56 UTC

    For shame! Where is

    s;{.*?};{$sub[$n++]};g;

    :-)


    ---
    demerphq

    <Elian> And I do take a kind of perverse pleasure in having an OO assembly language...
      's' is a fun delimiter, especially with a /s modifier and some variables named 's' for good measure. :)
      ss{.*?}s{$s[$s++]}ss;

      -Matt

        Might not be appreciated so much over here in Germany though...

        ;-)


        ---
        demerphq

        <Elian> And I do take a kind of perverse pleasure in having an OO assembly language...
      I wanted to leave some for the imagination :)
Re: Re: Whats your favorite nonstandard regex quote char?
by diotalevi (Canon) on Apr 22, 2003 at 15:56 UTC

    Yes I can see those being favorites for obfuscation - in general work its likely better to avoid the use of overly meaningful characters. I'd include sigils at the top of that list, then other things that are likely to confuse (like the pound character). I waver between the various bracketed characters - curly braces, square braces, chevrons and in last place parentheses. Which one I actually use is predicated on what the content of the expression is and whether it conflicts with my delimiters.

      Which one I actually use is predicated on what the content of the expression is and whether it conflicts with my delimiters.

      Naturally. But assuming that the only character that is out of bounds is the / which would you use and why?


      ---
      demerphq

      <Elian> And I do take a kind of perverse pleasure in having an OO assembly language...
Re^2: Whats your favorite nonstandard regex quote char? (backslash)
by Aristotle (Chancellor) on Apr 26, 2003 at 02:56 UTC
    s\{.*?}\{$sub[$n++]}\g;
    *evil grin*

    Makeshifts last the longest.