[Mpls-pm] Interesting RegEx Problem

Gypsy Rogers gypsy at freeq.com
Mon Sep 19 08:47:17 PDT 2005



The most straight forward is a series of elsif statements, not the prettiest
but it works clean.

if ($string =~ /regex1/){ $match = "regex1"; }
elsif ($string =~ /regex2/) { $match = "regex2";}
elsif ($string =~ /regex3/) { $match = "regex3";}
else { $match = "Your string is worthless"; }

No hubburis here, and I'm sure someone else will come up with a much more
fun and acrobatic way to do it, but I've learned to keep my code easy for Jr
Level coders to read to save me headaches. So, this works.
  


On Mon, 19 Sep 2005 10:30:21 -0500 (CDT), "Robert Fischer"
<rfischer at corradiation.net> wrote :

> I've got a problem that just came up at work.  Any help?
> 
> Given an arbitrary string and a collection of regular expressions, and
> assuming that one and only one of the regular expressions match the
> string, what is the best way to find the matching regular expression?
> 
> ~~ Robert Fischer.
> rfischer at corradiation.net
> 651-398-8010
> 
> _______________________________________________
> Mpls-pm mailing list
> Mpls-pm at pm.org
> http://mail.pm.org/mailman/listinfo/mpls-pm
> 
> 
> 


More information about the Mpls-pm mailing list