tags:

views:

23

answers:

1

Hi, I'm writing a quick PHP parser here and was wondering instead of writing

foreach($array as $line) {
  if(preg_match($regex1, ..) {

  } 
  elseif(preg_match($regex2, ..) {

  }
}

Is there possible to match against an array of regexes?

A: 
foreach($text_array as $line){
    foreach($regex_array as $regex{
        ...
    }
}
Álvaro G. Vicario
That's the best way to do it? =)
Michael Grons
Unfortunately I don't think this is a PHP Perl-style regular expression method that will do this. `preg_replace` and `preg_filter` both accept an array of expressions but they perform replacement in addition to matching.
Richard Cook
What strikes you from this approach as too complex? :)
Álvaro G. Vicario
Hehe, nothing. Was just wondering if I could match against an array..
Michael Grons