in reply to Regex OR'ing

$var =~ /regex(catch_this)/ || $var =~ /.{0}/;

Regex always prefer matches early in the string. For two matches starting at the same point in the string, regex prefers the one matching elements leftmost in an alternation, where alternations early in the regex are more important than those later. To break ties here, the regex prefers longer matches (or shorter matches for non-greedy elements).

Whether my snippet of code is of any use to you probably depends on other details you didn't mention.

Replies are listed 'Best First'.
RE: Re: Regex OR'ing
by spectre (Scribe) on Jul 28, 2000 at 03:23 UTC
    Ah, to clarify, I'm writing a module for a harness, I dont actually have the option of doing it that way.

    The interface needs to be like the following:
    $this->regex('key','regex'); In this case : $this->regex('high_bidder','(?:Date . Time<.B>.*?1\.<.B><.FONT><.TD> +\s+<TD[^>]+><FONT[^>]+>(.*?)<.FONT>|)');