On Tue, 21 Jan 2003, Dan Muey wrote:
>
>
> > Hi,
> >
> > my ($str) = "HI, HELLO, GREETINGS";
> > my ($reg) = "(BYE|HI|CIAO)";
> >
> > if ($str =~ /$reg/)
> > { print "Exists in $str\n"; }
> >
> > The above code, will return true if BYE, HI or CIAO exists
> > in $str.
> > I want a regex to be put in $reg, which will return true
> > if neither BYE, HI nor CIAO exists in $str
> >
> > I could've done something like:
> > if ($str !~ /$reg/)
> > { ... }
>
> Seems like if($str !~ /$reg/) {} would do what you want.
> What exactly are you trying to do?
>
> >
> > but, I don't want to change the code, just $reg.
>
> Not sure that's possible and I can't really see what benefit you'd get anyway.
But, it will help me!
I first go through a map-file, and insert all class names into
an array. Later while parsing through an HTML file, whenever I
find a TAG, I check to see if that tag has one of the class names
in the array.
This is where I use a regex. This way I can check for classes
like "text" and also for classes like "text[0-9]+"
This has proven to be very useful.
But now, I need to check for all classes other than "text";
This has me stumped!!
For eg:
$str = '<TD class="text1">';
$class = 'text[0-9]+'
if ($str =~ /class="$class"/)
{
print "TAG has this class\n";
}
bye,
George P.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]