in reply to Re: Useful Uses of regex code expressions?
in thread Useful Uses of regex code expressions?

A few corrections:

1. The (?(...)true|false) can also take a (?{ code }) block as its condition.

3. Uh, /[\Q$foo\E]/ works for me. The problem comes when you want to employ variables that are created as the regex matches (like the digit variables). Then it comes in handy. For example, /.(??{ "[^\Q$&\E]" })*/s finds a string of characters with no repeats.

You can see examples of code assertions in my book, whenever the hell I finish it.

_____________________________________________________
Jeff[japhy]Pinyan: Perl, regex, and perl hacker, who'd like a job (NYC-area)
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;

Replies are listed 'Best First'.
Re: Re: Re: Useful Uses of regex code expressions?
by jryan (Vicar) on Jun 27, 2002 at 22:19 UTC

    Regarding 1: That most certainly is an undocumented feature. According go perlre:

    (?(condition)yes-pattern|no-pattern) (?(condition)yes-pattern) Conditional expression. (condition) should be either an integer in par +entheses (which is valid if the corresponding pair of parentheses mat +ched), or look-ahead/look-behind/evaluate zero-width assertion.

    Update: I saw, and read that phrase; however, my brain hates me and skipped processing it correctly ;(

      Regarding 1: That most certainly is an undocumented feature

      It is documented in the chunk of perlre you quoted

      ... or look-ahead/look-behind/evaluate zero-width assertion.

      It can be an integer or

      • a look-ahead zero width assertion
      • a look-behind zero width assertion
      • an evaluate zero width assertion