On Feb 26, Paul Farley said: >I'm trying to use a regex to match a passed value. I'm trying to use an or >between the patterns, and it needs to be case insensitive. >I've tried it two ways, and it doesn't seem to work either way completely.
>if($ep =~ /^rglyc[12345] |^rglyd[235678] | ^rglyf3 | ^rglyg6 | ^rglyt5 | >^rglyu1/i) Uh... do you MEAN to have those spaces in there? I have a feeling they're killing your regex. For example, how could / ^foo/ EVER match? How can you match a " " before the beginning of the string? If you want to use whitespace in your regex for mere spacing, use the /x modifier. if (/ ^foo | ^bar | ^blat /x) { ... } Your regex can be shortened a bit, too. No sense in matching the SAME leading string OVER and OVER again: if ($ep =~ /^rgly(c[12345]|d[235678]|f3|g6|t5|u1)/i) { ... } > { > $org="LYX"; > subscription($ep,$pr,$sub,$org,$plat); > } > elsif ($ep =~ /^rglyv[34567] | ^rglyw[79]/i ) elsif ($ep =~ /^rgly(v[34567]|w[79])/i) { ... } > { > $org="LYP"; > subscription($ep,$pr,$sub,$org,$plat); > } >if($ep =~ /^rglyc[12345]/i |/^rglyd[235678]/i | /^rglyf3/i | /^rglyg6/i | >/^rglyt5/i | /^rglyu1/i) This method breaks because only the first regex is executed on $ep; all the others work on $_. And you're using BITWISE "OR", not logical "OR". if ($ep =~ /foo/ || $ep =~ /bar/ || ... ) { ... } But then you have to write lots of code, and you're executing LOTS of regexes. Icky. >1. How do I do an "or" in a regex if statement like this? >2. Is there a better(more efficient) way to do this? (I know that's a loaded >question to a perl list. <G>) See above. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]